running selenium webdriver with firefox profile results in WebDriverError: connection refused - selenium

I am trying to start a selenium test with the following command
selenium-side-runner --server http://127.0.0.1:4444/wd/hub --debug -c
"browserName='firefox' moz:firefoxOptions.args=[-profile, /home/seluser.
/firefox-profile/myprofile]" --output-directory ~/out ~/portallogin.side
The profile is loaded correctly in firefox then but the test fails to run with the following exception:
Test suite failed to run
WebDriverError: connection refused
Build info: version: '3.141.59', revision: '82b03c358b', time: '2019-04-30T22:04:50'
System info: host: 'd871aae50a23', ip: '172.17.0.3', os.name: 'Linux', os.arch:
'amd64', os.version: '4.4.0-1075-aws', java.version: '1.8.0_212'
Driver info: driver.version: unknown
remote stacktrace:
at Object.checkLegacyResponse (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/error.js:585:15)
at parseHttpResponse (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:551:13)
at Executor.execute (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:486:26)
While running the same test without the profile beeing loaded is working.
I have found this issue: https://github.com/SeleniumHQ/selenium-ide/issues/616 and it looks like a bug.
I tried to add a .side.yml file but that didn't help yet.
It looks like the loading of a profile is disabling the webdriver functionallity in firefox. Any hints how to get it running?

There is a workaround provided here https://github.com/mozilla/geckodriver/issues/1058#issuecomment-350254437
We need to pass the --marionette-port 2828 during the selenium execution.

Related

How to run selenium java test in linux in non-headless mode through docker

I know it works fine when I run in headless mode.
However is it possible to run in non-headless mode?
I've installed xvfb through docker and setting
ENV DISPLAY=:99
While running the test
docker run -e Xvfb ${DISPLAY} gradle <task name>
It always gives the error as
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: '4c3a51d1d7', ip: '<ip>', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.87-linuxkit-aufs', java.version: '1.8.0_222'

Exception when run Serenity tests on Jenkins in Seelnium grid

I run tests on my locale machine (not in grid), and it works. However, when I run on Jenkins, on Linux server in selenium grid, I have strange error:
net.serenitybdd.core.exceptions.SerenityManagedException: The following error occurred: Expected condition failed: waiting for core.common.utils.WebDriverUtil$$Lambda$195/1333459330#4f5c82fa (tried for 30 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'fr-woqa01', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-4-amd64', java.version: '1.8.0_131'
Driver info: net.thucydides.core.webdriver.WebDriverFacade
at net.serenitybdd.core.exceptions.SerenityManagedException.detachedCopyOf(SerenityManagedException.java:21)
at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:419)
at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:151)
at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:138)
at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:69)
at serenity.steps.HomePageSteps$$EnhancerByCGLIB$$c60d4147.openPage()
at jbehave.scenariosteps.LoginPageScenario.navigateToPage(LoginPageScenario.java:26)
(reflection-invoke)
at org.jbehave.core.steps.StepCreator$ParametrisedStep.perform(StepCreator.java:733)
at org.jbehave.core.embedder.PerformableTree$FineSoFar.run(PerformableTree.java:346)
I run test using command:
-pl ui verify -Dstory.file.name=${story_name} -Denv.config.file=qa.properties -Dwebdriver.remote.url=http://localhost:4444/wd/hub -Dwebdriver.remote.driver=chrome -Dwebdriver.remote.os=LINUX -Dchrome.switches="--no-sandbox,--ignore-certificate-errors,--homepage=about:blank,--no-first-run, --disable-gpu, --disable-impl-side-painting, --disable-gpu-sandbox, --disable-accelerated-2d-canvas, --disable-accelerated-jpeg-decoding, --test-type=ui"
Any help?
The error tells serenity cannot talk to webdriver. Which could be either due to chromedriver not avaliable on the jenkins slave/jenkins machine or chrome itself not installed on the jenkins machine.
Run these commands on to check if chrome /chrome driver is installed on jenkins machine
which chromedriver
which google-chrome

how disccover which selenium and chromedriver is used during polymer test

I get this error when running "Cannot establish new session" when I run "polymer test --skip-selenium-install"
error: [cli.main] Error: {"value":{"stacktrace":"org.openqa.selenium.SessionNotCreatedException: Cannot establish new session\nBuild info: version: \u00273.8.1\u0027, revisi
on: \u00276e95a6684b\u0027, time: \u00272017-12-01T19:05:32.194Z\u0027\nSystem info: host: \u0027WDU8L0001186\u0027, ip: \u002710.244.11.110\u0027, os.name: \u0027Windows 7\u0
027, os.arch: \u0027x86\u0027, os.version: \u00276.1\u0027, java.version: \u00271.8.0_172\u0027\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.server
.ServicedSession$Factory.apply(ServicedSession.java:261)\r\n\tat org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$apply$11(ActiveSessionFactory.java:167)\r\n\tat
...
e":"Cannot establish new session\nBuild info: version: \u00273.8.1\u0027, revision: \u00276e95a6684b\u0027, time: \u00272017-12-01T19:05:32.194Z\u0027\nSystem info: host: \u00
27WDU8L0001186\u0027, ip: \u002710.244.11.110\u0027, os.name: \u0027Windows 7\u0027, os.arch: \u0027x86\u0027, os.version: \u00276.1\u0027, java.version: \u00271.8.0_172\u0027
\nDriver info: driver.version: unknown","error":"session not created"},"status":33}
at C:\Users\D-CA69TO\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\web-component-tester\runner\steps.js:170:27
at Generator.next (<anonymous>)
at fulfilled (C:\Users\D-CA69TO\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\web-component-tester\runner\steps.js:4:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
By googling around I saw that this might be caused by wrong combination of Selenium, ChromeDriver and Chrome. Well, my Chrome is Version 66.0.3359.117 (Official Build) (32-bit) but how can I check which is the Selenium and ChromeDriver been used? Honestly, I don't remenber I installed them so I assume polymer-cli did this for me somehow.
*** Edited after Corey's suggestion
C:\>chromedriver -v
'chromedriver' is not recognized as an internal or external command,
operable program or batch file.
to get the chromedriver version: chromedriver -v
if you have the selenium python bindings installed, you can check the version with: python -c "import selenium; print(selenium.__version__)"
for example, in a shell you can do:
$ chromedriver -v
ChromeDriver 2.36 (0)
$ python -c "import selenium; print(selenium.__version__)"
3.11.0

Selenium Grid with Protractor: SessionNotCreatedError at Object.checkLegacyResponse

I'm new to Selenium Grid and I'm trying to execute a protractor test on a remote node.
I'm using a Virtual Machine as Hub, the Node is my local machine which is also the client.
Both hub and node are up and running.
I've set the property seleniumAddress correctly in the conf.js file.
So now when I execute my test by running protractor conf.js, I'm getting this error:
E/launcher - SessionNotCreatedError: Unable to create new service:
ChromeDriverService
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-
08T15:15:08.936Z'
System info: host: 'host-name', ip: 'ip-address', os.name: 'Windows 7',
os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_171'
Driver info: driver.version: unknown
at Object.checkLegacyResponse
I have no idea why I'm getting this error. I tried to fix it by running:
webdriver-manager clean
webdriver-manager update
but it didn't help.
I solved this problem by specifying the location of the chromedriver executable using the argument Dwebdriver.chrome.driver. This argument should be set when starting the node.
chromedriver documentation

Protractor tests fail to start on Safari Sierra and throwing driver.version: unknown, SessionNotCreatedError error

Protractor version: 5.1.2
Safari version: 10.1.2
I have enabled 'Allow Remote Automation' from Safari -> Develop and started the safari driver from cmd using the following command:
/usr/bin/safaridriver -p 8844
Now, trying to run the protractor tests using protractor conf.js. The tests fail to start with the following logs:
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-16T21:10:06.092Z'
System info: host: 'dyn-49-127-9-116.its.monash.edu.au', ip: 'fe80:0:0:0:479:1a15:751b:51d6%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: unknown
[15:28:40] E/launcher - SessionNotCreatedError: Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 32 milliseconds
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-16T21:10:06.092Z'
System info: host: 'dyn-49-127-9-116.its.monash.edu.au', ip: 'fe80:0:0:0:479:1a15:751b:51d6%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: unknown
at WebDriverError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
at SessionNotCreatedError (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:214:5)
at Object.checkLegacyResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:505:15)
at parseHttpResponse (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
at createDriver (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:167:33)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/index.js:632:14)
at Hosted.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.ts:60:29)
at Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.ts:225:39)
at q.then.then (/usr/local/lib/node_modules/protractor/lib/runner.ts:391:27)
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:556:49
[15:28:40] E/launcher - Process exited with error code 19
I figured out the issue. Since built in safari driver has a limitation of only one browser window at a time, I quit all the running safari windows and ran the tests again. Worked perfectly fine :)
Reference:
https://webkit.org/blog/6900/webdriver-support-in-safari-10/
Kinda tricky, because currently it's not quite working due webdriver/selenium incompatibilities. We are hoping that, with the new webdriver release, it will work. See here.