Running Chrome WebDriver on a linux server with no display - google-chrome

I'd like to run automated tests using selenium2's chrome webdriver on a linux server.
I've already set up firefox to run on the server by using Xvfb (See http://www.semicomplete.com/blog/geekery/xvfb-firefox.html) and would like to do something similar with chrome. Is this possible?

I was facing the same challenge of setting a linux box with selenium + chromedriver,
and here's my notes:
Pre-reqs:
Install JRE to run the selenium jar
Install the selenium server
grab the jar file from https://code.google.com/p/selenium/downloads/list)
Install xvfb (you've seem to have already achieved this part)
Install google-chrome for your linux distribution
Download the chrome driver
You can grab it from here: https://sites.google.com/a/chromium.org/chromedriver/downloads
Install other selenium dependencies that you might need (but the above is the minimum to get chromedriver to work)
To run:
Run xvfb
Xvfb :1 -screen 5 1024x768x8 &
export DISPLAY=:1.5
Run the selenium server jar with ChromeDriver options.
It'll look something like this:
java -jar selenium-server-standalone-2.30.0.jar -Dwebdriver.chrome.bin=/path/to/google-chrome -Dwebdriver.chrome.driver=/path/to/chromedriver
The selenium server log should output something similar to this:
Mar 19, 2013 10:07:27 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.bin to {location of google-chrome}
Setting system property webdriver.chrome.driver to {location of chromedriver}
10:07:34.258 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:07:34.259 INFO - Version Jetty/5.1.x
10:07:34.259 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
...
Reference:
http://www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html
Cheers!

According to SetEnvironmentProperty to ChromeDriver programatically you can do the following:
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("/path/to/chromedriver"))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY",":20"))
.build();
Here is the documentation for withEnvironment

I haven't been able to find a way to do this programmatically for the ChromeDriver like you can with the FirefoxBinary.
I've submitted a improvement request which has a patch attached to allow this. You can see it here: http://code.google.com/p/selenium/issues/detail?id=2673
Edit:
You can see below response from Stephen on how to use this now the change has been merged.: https://stackoverflow.com/a/16619608/998442

I get what you are trying to do, but you probably just run selenium grid. It was made for automated browser testing. Works great on a server.
https://www.selenium.dev/documentation/en/grid/

Related

Browser Automation using Bash On Ubuntu On Windows

We have a strong regression automation suite developed with Watir for Web Apps and Calabash for IOS and Android and so far our executions are happening on Mac OS.
We want to use RVM on Windows 10 so enabled bash feature on Windows 10 and installed RVM using Bash On Ubuntu On Windows. Using this installed RVM I would like to trigger the browsers installed on my Windows. I would like to know whether I am trying something that is possible ?
Just to check, I tried to trigger chrome browser in irb.
I placed my chrome driver below.
I have set my path and find the same below
On triggering chrome browser in irb I am getting the below error even though the path is set correct.
Selenium::WebDriver::Error::WebDriverError: Unable to find chromedriver.
I would like to know whether trying to trigger the browser installed on my windows environment through the Bash On Ubuntu On Windows terminal is practically possible attempt or not ? If so, please let me know where the disconnect had happened in my setup.
Below are the versions I am installed with .
rvm 1.29.3 (latest)
ruby-2.2.7
watir (6.8.4)
The error you are getting generally indicates that you have installed the chromedriver.exe file into a directory that is not on your path. Either move the file to a directory that is in the default path, or modify the path to add the directory with chromedriver.exe to the path.
Generally it's best to do that with the default path set by Windows on boot-up lest you have to have some batchfile that is run to alter the path before running IRB or a script that runs your tests.
Use the webdrivers gem. It ensures you always have the latest chromedriver.exe in your ~/.webdrivers directory, by downloading the newest version as necessary. It directs the Ruby code to use that driver regardless of what other chromedriver is on your system and whether it is or isn't on PATH.

WebStorm debug mode not working and get message Process finished with exit code -1073741819 (0xC0000005)

I have recently downloaded WebStorm 11.0.3 to run my Protractor test cases. My test cases run fine when run normally (i.e. run from run configurations) but when I try to run my test cases in debug mode nothing really happens and I get the following in the console:
"C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=58467 --nolazy c:\Users\daobrien15\AppData\Roaming\npm\node_modules\protractor\lib\cli.js conf.js
Debugger listening on port 58467
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Process finished with exit code -1073741819 (0xC0000005)
When I run debug against Firefox it just launches the first run Firefox screen and does nothing. When I run it against Chrome it just loads a blank page with data:, in the URL bar and also does nothing.
I am using the following:
OS: Win 7 (64 bit)
Protractor: 3.0.0
Selenium webdriver: 2.48.2
Firefox: 35 as the latest was not working with my tests when run normally
Chrome: 47.0.2526.111 m (Latest)
Also I am running my selenium webmanager through the console. I get pretty much the same result if I use the directConnect option in my conf.js file:
directConnect: true,
Any help would be greatly appreciated.
I have had same problem.
Check version of node.js in your webstorm terminal: node --version
My version was 5.2 and I had this bug.
Today I update node to 5.5.0(last stable) and this problem gone.
NOTE: If you use Webstorm 9 or 10 go to
C:\Program Files (x86)\JetBrains\WebStorm 9.0\bin
and open WebStorm64.exe.vmoptions and WebStorm.exe.vmoptions and in the end set
-Dnodejs.debugger.use.jb.support=false
this will help to stop on your breakpoint.
If you use Webstorm 11 you will not have this problem, but if you will - use fix for WebStorm 9/10.
Hope this will help you.
I have had some problem. I was tried #user3552 solution but not worked for me second time. I checked my node params and removed this param from my node params. This is working now.
--debug-brk=8081
Before removing one param my exec code was like this
/home/veysel/.nave/installed/5.0.0/bin/node --debug-brk=37621 -debug-brk=8081 --expose_debug_as=v8debug /opt/lampp/htdocs/kart/server.js 8080
After removing the last exec code like this.
/home/veysel/.nave/installed/5.0.0/bin/node --debug-brk=37621 --expose_debug_as=v8debug /opt/lampp/htdocs/kart/server.js 8080

Visual Studio 2013 native cordova app build error

I just installed and repaired my VS2013 to build Native Cordova App. I have also installed the latest version of NodeJS but whenever I am trying to build the Application It gives me an error. I am uploading an image for more details on error as I believe image provide more info than text.
Posting error details if error is not clear in an image
Cannot find module 'q'.
The command ""C:\Users\nnnc\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" prepare --platform Android --configuration Debug --projectDir . --projectName "BlankCordovaApp1" --language "en-US"" exited with code 8. C:\Users\nnnc\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets
I have advanced a little bit more but having hard time to run the application I have to manually installed all the required module. but now whenever I am running my project I get an error of web page is not available. please look at the attached image again.
I found that running npm install from within /vs-mda/ solved all my problems.
found the fix and that Involved manually loading packages like q via node js and in the end the fix for web page is not available was that ripple has changed and now we should not add it as an extension via chrome. it should be done via node js as well as below
npm install ripple -g
but before doing that delete it from chrome if you have got it otherwise just run the command.
Regards

Chromedriver failing to launch or connect

Up until today, I have been using chromedriver to drive my watir-webdriver tests, and I have had no problems. My server still works and runs tests on the same version of the chromedriver and chrome.
I have tried updating to the latest chromedriver, which is the chromedriver 2 experimental build. This fails due to what I can only assume are still bugs being worked out of it.
I have also tried rolling back to the previous version of chromedriver with no success.
If anyone has any experience with this, I would really appreciate your expertise. I am sure it will turn out to be something simple I have overlooked.
gem versions:
watir-webdriver (0.6.2)
selenium-webdriver (2.29.0)
cucumber (1.2.1)
trace from the chromedriver below
Started ChromeDriver port=9517 version=26.0.1383.0
log=C:\Projects\oms_acceptance_tests\src\chromedriver.log
[6136:5300:0212/122320:ERROR:master_preferences.cc(110)] Failed to read master_preferences file at C:\Program Files (x86)\Google\Chrome\Application\master_preferences. Falling back to default preferences.
[6136:5300:0212/122320:ERROR:gpu_info_collector_win.cc(82)] Can't retrieve a valid WinSAT assessment.
test\automation\proxy_launcher.cc(107): error: Value of: app_launched
Actual: 5
Expected: AUTOMATION_SUCCESS
Which is: 0
Error while awaiting automation ping from browser process
[0212/122321:ERROR:proxy_launcher.cc(556)] Failed to ConnectToRunningBrowser
[0212/122321:ERROR:automation_proxy.cc(319)] Channel error in AutomationProxy.
Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe (Selenium::WebDriver::Error::UnknownError)
I would trying downloading newer version of chromedriver. Worked for me when I experienced similar issues.
To get rid of the gpu winsat error, try to update your display adapter.

Selenium Standalone fails to run tests in Google Chrome [duplicate]

This question already has answers here:
How to run Google Chrome with Selenium RC?
(5 answers)
Closed 9 years ago.
I'm using jenkins to run selenium standalone server and html test suites in a windows xp node.
I've managed to get it running and working for iexplore and firefox, but when it comes to googlechrome it fails in starting it.
This is the command I use to run the tests in googlechrome:
java -jar C:\...\selenium-server-standalone-2.28.0.jar -htmlSuite "*googlechrome C:\Program Files\Google\Chrome\Application\chrome.exe --allow-file-access-from-files –-disable-web-security" file:///C:/WebTest/Tests/ C:/WebTest/Tests/TestSuite.html C:\jenkins\workspace\sp-webTest\resultados\resultadoGC.html
And the error I get is:
12:43:08.044 INFO - Launching Google Chrome...
HTML suite exception seen:
java.lang.NullPointerException
at org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.createCommandArray(GoogleChromeLauncher.java:168)
at org.openqa.selenium.server.browserlaunchers.GoogleChromeLauncher.launch(GoogleChromeLauncher.java:82)
at org.openqa.selenium.server.browserlaunchers.AbstractBrowserLauncher.launchHTMLSuite(AbstractBrowserLauncher.java:47)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:145)
at org.openqa.selenium.server.htmlrunner.HTMLLauncher.runHTMLSuite(HTMLLauncher.java:196)
at org.openqa.selenium.server.SeleniumServer.runHtmlSuite(SeleniumServer.java:611)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:285)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:243)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)
Any help will be appreciated.
Specifying the webdriver in java helps.
System.setProperty("webdriver.chrome.driver", "c:/chromedriver.exe");
driver = new ChromeDriver();
Download link for chrome driver http://code.google.com/p/chromedriver/downloads/list
I got it working, somehow sending flags to chrome in the command causes selenium to throw null pointer exception. So what I did was add chrome to the PATH in mi xp node, use Selenium plugin to run html test suites in jenkins and specify a start url that begins with "https://" using google chrome and a start url that begins with "file:///" was a mess and couldn't get it to work like that. I also added the -trustAllSSLCertificates in "others" input box.
For me on Windows it work:
java -jar "c:\selenium-server-standalone-2.35.0.jar" -forcedBrowserMode "*googlechrome c:\Program Files\Google\Chrome\Application\chrome.exe"