Runnig selenium Grid - selenium

I am trying to run a test using the selenium server which will enable cross browser testing, but I'm getting this error
I have downloaded the standalone server and ran it through comand prompt and got a grid console such as the image file attached and my guess is only webdriver part is enabled and remote control part is not if so PLease guid me on how to solve this [Grid console][1]
this is the error
FAILED: test
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 256 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'AKHIL-PC', ip: '192.158.0.29', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver

The error suggests that you are missing chrome driver. did you download the chrome driver form here?
Did you add the chrome driver to your path variable
In Windows, goto System -> Advanced System Settings -> Advanced (Tab) -> Environment Variables
Under System variables, scroll to the Variable named Path -> Edit… (button) -> Variable value ->
Scroll to the end of the field, add a semicolon and append the local path of chromedriver.exe to the
end of the value field. Click OK:
To verify, open the Command Line (Run cmd.exe) -> Type chromedriver ->Hit Enter -> ChromeDriver
Also, restart the selenium standalone hubs and nodes
Let me know if it works
EDIT:
And if you configure your node via a xml file like:
{
"capabilities":
[
{
"browserName": "chrome",
"platform": "WINDOWS",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"webdriver.chrome.driver": "C:/Selenium/drivers/chromedriver.exe",
"binary":"C:/Program Files/Google/Chrome/Application/chrome.exe"
}
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "<address to hub>",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Change the webdriver.chrome.driver and binary to your own path.
and the to your hub url
And start your node via:
java -jar selenium-server-standalone-<version>.jar -role node -nodeConfig nodeConfig.json

Related

LocalFileDetector can't find uploaded files in Selenium Grid tests

I'm using Selenium Grid to run some automated tests that always worked locally. I've created a RemoteWebDriver object, and used remoteDriver.setFileDetector(new LocalFileDetector()) to activate the local file detector. All of the pages I can find list this as the only solution, as if nothing can possibly go wrong with it.
In summary, selenium is definitely uploading the files from my local Windows filesystem, to Selenium Grid running on Linux. GeckoDriver can find it just fine, but ChromeDriver says it's not found:
invalid argument: File not found : /tmp/41dd2016f9974950127c20f7d25df461/upload7388365119198958794file/hasThemesWithImages.zip
(Session info: headless chrome=109.0.5414.74)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'PAX-314945', ip: '192.168.50.241', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16.1'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 109.0.5414.74, chrome: {chromedriverVersion: 109.0.5414.74 (e7c5703604da..., userDataDir: /tmp/.org.chromium.Chromium...}, goog:chromeOptions: {debuggerAddress: localhost:39795}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 41dd2016f9974950127c20f7d25...}
Session ID: 41dd2016f9974950127c20f7d25df461
If I ssh to the remote host while it's still running, and type ls -l and paste in that long pathname, then I see the file is present. It's the correct size, and has global read permissions. I can even examine the zip contents. And yet, chromedriver gives the error above.
I started the grid server with a very simple java -jar selenium-server-standalone-3.141.59.jar command, with no other options, and am using Chromium in headless mode.
I have tried starting Chromium with and without --no-sandbox and --disable-dev-shm-usage as command line options.
I'm using Geb 3.4.1 and Groovy 2.x on the client side, and it looks like I'm doing everything correctly. I tried a few different tests that worked locally before, and added some logging in the test to confirm that driver.getFileDetector() returned the LocalFileDetector instance. Here is the relevant portion of my GebConfig.groovy file:
def remoteWebDriver(Capabilities capabilities) {
URL hubUrl = new URL("http://192.168.1.5:4444/wd/hub")
new RemoteWebDriver(hubUrl, capabilities)
}
FirefoxProfile myFirefoxProfile() {
// omitted; I hope it's not important.
}
environments {
gridFirefox { // file uploads work
driver = {
println "creating a RemoteDriver"
FirefoxOptions opts = new FirefoxOptions()
opts.addArguments("--headless")
opts.profile = myFirefoxProfile()
RemoteWebDriver remoteDriver = remoteWebDriver(opts)
remoteDriver.setFileDetector(new LocalFileDetector())
remoteDriver
}
}
gridChrome { // file uploads don't work
driver = {
println "creating a Chrome RemoteDriver"
ChromeOptions chrome_options = new ChromeOptions()
chrome_options.addArguments("--window-size=1600,1100")
chrome_options.addArguments('--headless')
//chrome_options.addArguments('--no-sandbox')
//chrome_options.addArguments('--disable-dev-shm-usage')
RemoteWebDriver remoteDriver = remoteWebDriver(chrome_options)
remoteDriver.setFileDetector(new LocalFileDetector())
remoteDriver
}
}
}

How to run selenium tests on Safari using Selenoid?

I'd like to ask, maybe somebody had experience with running automation tests on Safari (there are some strict limitations for Windows and Linux machines). One approach that I detected - it's Selenoid (but when run it, I get: "
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.0.0', revision: '......'
System info: host: 'runner-ovqpgybp-project-31983248-concurrent-0', ip: '.....', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1017-gcp', java.version: '17.0.1'
selenide.remote: http://localhost:4444/wd/hub
Let me know if there exist some solution or workaround, please.
We provide Webkit-based Docker images for that:
$ cat browsers.json
{
"safari": {
"default": "15.0",
"versions": {
"15.0": {
"image": "browsers/safari:15.0",
"port": "4444",
"path": "/"
}
}
}
}
This is not a real Safari, but browser engine is the same and it works in Docker.

Selenium Grid Driver.Version Unknown

I know that this question is asked many times and the answers helped me once.
I used to start as an experiment a Selenium Grid Hub on my local machine and an Node on an other machine. Both were started using parameters on the command line. I was able to start a test so the configuration worked.
Since I do not want to run the hub on my local machine I started is on the same machine as the node but now using JSON config files.
Now I get the WebDriverException: Error forwarding the new session cannot find ... giving the driver.version: unknown error.
I am sure that I pass the version so the error leaves me puzzled.
The node is according to the hub's out put correctly registered. The nodeconfig JSON is:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"version": 93,
"platform": "WIN10"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
The console output in Eclipse shows this error description:
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'XXXXXXXXXX', ip: 'ipx.xxx.xxx.xxx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_302'
Driver info: driver.version: unknown
The hub show following:
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
org.openqa.grid.common.exception.CapabilityNotPresentOnTheGridException: cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
The Chrome version on the node is 93.0.4577.82. Do I need to spell this out?
Can anyone give me a clue how to solve this?
All examples on the net are showing version numbers like 93.0 or 93 .
So yes, I had to spell it out like 93.0.4577.82

Unable to find page elements with Behat / Mink using Selenium 3.5.x

I am working on setting up behavioral tests for our current website. I have used Behat in the past with Selenium standalone server and now have updated to the latest Behat 3 and Selenium 3.5. I am having a multitude of issues though. Using Selenium 3.5 I cannot get xpath selectors to work at all. It is not able to find elements by id, name, class etc. With Selenium 3.4.x it seems to work fine but I cannot get button presses to work. I receive this error:
Then I click button "loginBtn" # FeatureContext::iClickButton()
mouseMoveTo
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'matt-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-59-generic', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver (WebDriver\Exception\UnknownCommand)
This seems to be something that was fixed in 3.5.x with enablePassThrough set to true. Here is my behat.yml configuration.
default:
suites:
default:
contexts:
- FeatureContext:
screenshots_path: '%paths.base%/screenshots/firefox/'
extensions:
Behat\MinkExtension:
base_url: 'http://localhost:8080/customer_portal/'
default_session: selenium2
browser_name: 'firefox'
selenium2:
browser: 'firefox'
capabilities:
browserName: 'firefox'
browser: 'firefox'
version: ''
wd_host: 'localhost:5555/wd/hub'
And inside of my composer.json file
{
"require": {
"behat/behat": "3.*#stable",
"behat/mink": "1.7.*#stable",
"behat/mink-selenium2-driver": "#stable",
"behat/mink-goutte-driver": "#stable",
"behat/mink-extension": "#stable",
"phpmd/phpmd" : "#stable"
},
"config": {
"bin-dir": "bin/"
}
}
I am using Firefox 55 and geckodriver v18. Has anyone successfully configured selenium to work with Behat 3 and Firefox?
It seems to be an issue from Selenium. I also have the issue when working with FF and could not get the Element clicked.
mouseMoveTo error is well known issue when using selenium3. This error happens only for firefox browser with gecko driver. To fix this issue you can use chrome or update the MinkSelenium2Driver library. Should be master branch of MinkSelenium2Driver which requires behat/mink: ~1.7#dev. Here is the point of the problem MinkSelenium2Driver So if its ok for you to use all the latest behat versions, then composer.json could looks like this:
"require": {
"behat/behat": "v3.3.1",
"behat/mink": "v1.7.1",
"behat/mink-extension": "v2.2",
"behat/mink-selenium2-driver": "dev-master",
}

WebDriver grid configuration throws error

I have the following setup:
I am running a grid hub on my local pc with the following config:
java -jar selenium-server-standalone-2.42.0.jar -role hub -grid1Yml grid_configuration.yml
the config looks like this:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "Firefox on Windows"
browser: "*firefox"
...
I am starting the node via
java -jar selenium-server -standalone-2.42.0.jar -role node -hub http://localhost:4444/grid/register -port 8888 -browser "browserName=Firefox on windows,maxInstances=1,version=1,platform=WINDOWS"
My Test setup looks like this:
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("*firefox");
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4444" + "/wd/hub"), cap);
}
If i run my test i get the following error:
Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding
the new session webdriver new session JSON response body did not contain a session ID
Command duration or timeout: 946 milliseconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'CL-CNU416C97F', ip: '10.11.112.158', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
In the webdriver node i get the important error:
Exception: The path to the driver executable must be set by the webdriver.ie.driver system property...
I have set this property via java and in my windows environment. I do not know why i am still getting this error message.
UPDATE
If i use the grid2 config file (json), how is it possible to set an individual browser by name on each host.
Example:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "MyFireFox on MyMachine1"
browser: "*firefox"
- name: "MyFireFox on MyMachine2"
browser: "*firefox"
If i use this hub config i can start a node by saying it is a "MyFireFox on MyMachine1" Browser. The attribute browser is telling webdriver to use Firefox on the system
If i now use the grid2 config json, i have the following
{
"capabilities":
[
{
"browserName": "MyFireFox on MyMachine1",
"platform": "WINDOWS",
"maxInstances": 1
},
but this will not work, because i think the browserName is what browser was in grid1 config.
this is config from my .bat files. also, why do you change your node port to 8888 ? try to remove '-port 8888' and check again
for hub:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role hub
for node:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox, platform=WINDOWS
here is my json and bat file which 100% works
{
"capabilities":
[
{
"browserName": "firefox",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "internet explorer",
"version": "10",
"platform": "WINDOWS",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"192.168.3.104",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
and bat to start node from json
java -jar selenium-server-standalone-2.41.0.jar -role node -nodeConfig nodeConfig_win7.json
also in system PATH you should add path to folder with drivers for browsers