Setting up selenium grid to use Microsoft edge - selenium

Environment:
win10 (build 10240)
Vaadin Testbench 4.1
Selenium 2.53
Drivers for Firefox, Chrome, IE11 and Edge for build 10240
Node and hub
start java -jar c:\users\powder\vaadin-testbench-standalone-4.1.0.jar -role hub
start java -jar c:\users\powder\vaadin-testbench-standalone-4.1.0.jar -role node -Dwebdriver.edge.driver=c:\users\powder\MicrosoftWebDriver.exe
Usage in java code
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName(DesiredCapabilities.edge().getBrowserName());
//DesiredCapabilities capabilities = DesiredCapabilities.edge(); Tried as well
capabilities.setCapability("acceptSslCerts", "true");
setDriver(new RemoteWebDriver(new URL(this.remoteHubUrl), capabilities));
getDriver().get("http://www.google.com");
Errormessage
Error forwarding the new session cannot find : Capabilities [{acceptSslCerts=true, browserName=MicrosoftEdge}]
Selenium grid console - edge is missing
Everything is working fine with other browsers, but not with Edge. Any ideas how to fix that?

There are 2 problems here:
First, if you look at the default node config you will notice that only Firefox, Chrome and IE are enabled by default (that's why all you need to use them is specify driver location via a system property). If you want to use any other browser then you need to use your own json config:
{
"capabilities": [
{
"browserName": "MicrosoftEdge",
"platform": "WIN10",
"maxInstances": 1
},
{
"browserName": "firefox",
"platform": "WIN10",
"maxInstances": 5
},
{
"browserName": "chrome",
"platform": "WIN10",
"maxInstances": 5
},
{
"browserName": "internet explorer",
"platform": "WIN10",
"maxInstances": 1
}
],
"hub": "http://selenium-hub-host:4444"
}
and pass it to your command line:
java "-Dwebdriver.edge.driver=c:\path\to\MicrosoftWebDriver.exe" "-Dwebdriver.gecko.driver=c:\path\to\geckodriver.exe" "-Dwebdriver.chrome.driver=c:\path\to\chromedriver.exe" "-Dwebdriver.ie.driver=c:\path\to\IEDriverServer.exe" -jar "c:\path\to\selenium-server-standalone.jar" -role node -nodeConfig "c:\path\to\the\above.json"
(btw: alternatively you can also put the whole config in your command line using multiple -capabilities or -browser params)
This in theory should work. However in practice you will often be hit by the 2nd problem, which is: "sometimes it randomly doesn't work" ;] Initially everything will look fine: your grid will properly report Edge browser capability on the console, it will properly delegate tests to a node containing Edge, the node will properly start Edge browser, however the browser will sometimes freeze on its initial blue screen with e logo and after few seconds you will get some exception on the client side without any meaningful stack-trace nor message (I don't have it saved anywhere to paste here now).
Some people suggested a workaround to start 2 separate nodes on the same machine (on different ports of course) : one only for Edge and second for IE, FF and Chrome. This way it seems to work pretty stable (tested on Edge build 15063 running on win-10 and Selenium-3.4.0)
Additional info:
Apart from the above, Edge driver has few limitations that require specific workarounds in the configuration:
currently only 1 concurrent session is supported by the driver/browser so maxInstances must be set to 1 (kudos to this answer)
the driver must be running in the foreground, so that the browser window can be actually displayed on the desktop. Therefore the node cannot be started as a Windows Service nor from Windows Task Scheduler at startup. The best way to automate starting of the node is to configure auto-login and add a batch script starting the node to user's Startup Programs as described in my article

Try putting the -D parameters before the -jar parameter. I had an issue where it thought -Dwebdriver..... was a parameter to selenium itself instead of java.

Related

WebdriverIO setting browser language problem for headless chrome browser on linux server

I am using webdriverio for test automation and I am trying to change my chrome browser configurations via wdio.config.js file. I am running chrome headless browser and locally everything geos fine, but on the linux server it looks like the language setting doesn't take an effect.
An additional detail is that I have 2 jobs in the pipeline (1 for English and one for Netherlands language) but it seems both of them are running in English.
Here are my browser capabilities section:
{
maxInstances: 1,
browserName: 'chrome',
'goog:chromeOptions': {
args: [
'--headless',
'--disable-dev-shm-usage',
'--disable-gpu',
'--window-size=1920,1080',
'--disable-web-security',
'--lang=nl',
'ignore-certificate-errors'
],
},
}

Webdriver.io: what's the difference between the capabilities and desiredCapabilities keywords?

I'm using Webdriver.io to run UI tests in a Node environment.
I'd like to run Headless Chrome and came up with the following working configuration:
{
capabilities: [{
browserName: 'chrome',
args: ['--headless', '--disable-gpu']
}
}],
services : ['selenium-standalone'],
execArgv : ['--inspect']
}
However, I can't figure out whether capabilities is deprecated or not; I'm wondering because all the examples I see reference desiredCapabilities instead.
If I use desiredCapabilities though, then Chrome runs normally, not in headless mode.
I feel like I'm missing something, but I don't know what. Is there a significant difference between the two, and is one going away?
Thanks!
If you run webdriverio through the test runner (using a wdio.conf.js file), it uses capabilities.
If you run it in standalone mode (e.g. node myTest.js), it uses desiredCapabilities

Nightwatch tests do not find elements in Headless chrome mode

I am trying to get my tests (written in Nightwatch.js) to run locally in headless chrome.
However, the tests fail since they are not able to find the elements in headless mode (they work without headless mode though).
If I check the failure screenshots I only get a white screen.
But if test checks for the "body" element, it actually pass. So I think the page is loaded, but maybe headless chrome, for some reason, cannot load the javascript? Later I wait for divs and buttons etc to be visible for several seconds, but it does not find them.
Do you have any ideas what could be wrong?
I have added the --headless and --disable-gpu flags in desiredCapabilities in the nightwatch config file.
So, as I said in my reply I had the same issue yesterday, I was just trying to do a dummy test on google homepage. This morning with a fresh brain I tried to tackle that. I had the brilliant idea to take a screenshot just before nightwatch fails to find an element.
It turns out the "normal" chrome had the home page in English, and the "headless" chrome had the homepage in french, for some reason.
I found this: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1925 may be explaining why.
The workaround I found to always have the correct language is:
"chromeOptions" : {
"args" : ["--lang=fr", "--headless"]
}
I still have a hard time setting it in english (weirdly) but I hope this will save someone a couple of hours in the future
I think you should declare binary path in Nightwatch.js
If you are on linux please try this, it works perfectly for me :
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"headless", "disable-gpu"
],
"binary": "/usr/bin/google-chrome"
}
}
If you are on Mac, replace your binary path, eg /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

Selenium doesn't start webdriver

versions
"nightwatch": "^0.9.16"
"chromedriver": "^2.30.1"
"selenium-server-standalone-jar": "^3.4.0"
I'm using nightwatch but that sh
I also tried with
I'm using nightwatch to run Selenium in this repo and I've tried with chrome and firefox drivers, no luck on either.
I have selenium standalone and chromedriver packages, and I know the path is right on nightwatch.conf.js:
const jar = require('selenium-server-standalone-jar')
console.log(jar.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.4.0.jar
const chromedriver = require('chromedriver')
console.log(chromedriver.path) // logs /home/goldylucks/apps/ci-workshop/node_modules/chromedriver/lib/chromedriver/chromedriver
'selenium': {
'start_process': true,
'server_path': jar.path,
'log_path': '',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': chromedriver.path,
'webdriver.ie.driver': '',
},
},
'test_settings': {
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
},
},
yet when I run the test it times out and hangs:
$ yarn e2e:ui
yarn e2e:ui v0.24.6
$ nightwatch -e chrome
Starting selenium server... started - PID: 12936
[App E2e Ui] Test Suite
===========================
✖ Timed out while waiting for element <body> to be present for 5000 milliseconds. - expected "visible" but got: "not found"
at Object.before (/home/goldylucks/apps/ci-workshop/test/ui/app.e2e-ui.js:9:8)
I tried it with the following combinations:
1. with the express server which serves the app on another terminal
2. without the express server
3. each of the above with chromedriver manually started at another terminal (I really don't think it should matter and that I should do this, just wanted to be thorough ...)
running the chromedriver manually yields the following and hangs:
$ node_modules/chromedriver/lib/chromedriver/chromedriver
Starting ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5) on port 9515
Only local connections are allowed.
I also tried running with firefox and it didn't work, which leads me to believe the problem is deeper than the chromedriver, i.e. related to selenium interacting with nightwatch.
I recall this happening a while back. I think it was that a previous instance Selenium had not closed freed port 4444 when shutting down. Try shutting down selenium and restarting.
To do that, open the following webpage manually, in the browser of your choice.
http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer
Then try running the script again as normal.

Run parallel Protractor tests in multiple Chrome tabs

I'm using the following .conf:
capabilities: {
browserName : 'chrome',
shardTestFiles: true,
'time-zone': 'AEST',
maxInstances: 5,
singleWindow: true
}
I'm using singleWindow as described in the capabilities page for Selenium and the properties are passed to the WebDriver according to this. However I'm still seeing multiple individual windows appearing and disappearing during execution. These fight for focus and it's very annoying while doing other work.
Is it possible to run parallel tests in separate tabs rather than separate instances/windows of Chrome?