Hi @Josh-Ghazi, I am also struggeling with selenium and want to do some testing.
Also ended up with having a docker selenium grid and doing HTTP Requests to the Selenium HUB like this:
1. Create a Session
POST http://localhost:4444/wd/hub/session
Body Payload:
{
"desiredCapabilities": {
"browserName": "firefox",
"timeouts": {
"implicit": 5000,
"pageLoad": 300000,
"script": 30000
}
},
"capabilities": {
"firstMatch": [{}],
"alwaysMatch": {
"browserName": "firefox"
}
}
}
2. Navigate to a Page
POST http://localhost:4444/wd/hub/session/“sessionId”/url
Body Payload:
"url": "https://www.google.com"
}
3. Take a Sreenshot
GET http://localhost:4444/wd/hub/session/“sessionId”/screenshot
The Screenshot is served in a Base64 Values and has to be converted with the “Move Binary Data” node:
4. Delete Session
DELETE http://localhost:4444/wd/hub/session/“sessionId”
My problem is that I cannot get scripts to work which I created with Selenium IDE · Open source record and playback test automation for the web
I do the following which is failing with timouts (and I removed the timeouts and also multiplied them without any other result).
POST http://localhost:4444/wd/hub/session/“sessionId”/execute/async
The script has to be handled with {{ JSON.stringify($json["testscript"]) }}
to get recognized. But they are still timing out.
Body Payload:
{
"script": "('testrun', async function() {\n await driver.get(\"https://www.google.com/\")\n await driver.manage().window().setRect({ width: 1075, height: 896 })\n await driver.findElement(By.css(\"#W0wltc > .QS5gu\")).click()\n await driver.findElement(By.name(\"q\")).click()\n await driver.findElement(By.name(\"q\")).sendKeys(\"selenium webdriver api\")\n await driver.findElement(By.css(\"form > div:nth-child(1)\")).click()\n await driver.findElement(By.css(\"center:nth-child(1) > .gNO89b\")).click()\n {\n const element = await driver.findElement(By.css(\".MjjYud:nth-child(1) > div:nth-child(1) > .g:nth-child(1) .LC20lb:nth-child(2)\"))\n await driver.actions({ bridge: true }).moveToElement(element).perform()\n }\n await driver.findElement(By.css(\".MjjYud:nth-child(1) > div:nth-child(1) > .g:nth-child(1) .LC20lb:nth-child(2)\")).click()\n await driver.findElement(By.css(\"#m-documentationwebdriveractions_api > span\")).click()\n })"
}
Non-Stringify script (just a simple demo browing google for selenium webdriver api)
('testrun', async function() {
await driver.get("https://www.google.com/")
await driver.manage().window().setRect({ width: 1075, height: 896 })
await driver.findElement(By.css("#W0wltc > .QS5gu")).click()
await driver.findElement(By.name("q")).click()
await driver.findElement(By.name("q")).sendKeys("selenium webdriver api")
await driver.findElement(By.css("form > div:nth-child(1)")).click()
await driver.findElement(By.css("center:nth-child(1) > .gNO89b")).click()
{
const element = await driver.findElement(By.css(".MjjYud:nth-child(1) > div:nth-child(1) > .g:nth-child(1) .LC20lb:nth-child(2)"))
await driver.actions({ bridge: true }).moveToElement(element).perform()
}
await driver.findElement(By.css(".MjjYud:nth-child(1) > div:nth-child(1) > .g:nth-child(1) .LC20lb:nth-child(2)")).click()
await driver.findElement(By.css("#m-documentationwebdriveractions_api > span")).click()
})
Could anyone assist in this problem. Like this we could start a Selenium node, which would require your Selenium Hub URL and can be used with predefined commands?
Docs: WebDriver / Grid endpoints | Selenium