How to set the Chromedriver path using WDIO selenium-standalone service - selenium-chromedriver

I'm using some hosted agents to run tests in WDIO using the selenium-standalone-service.
I have agents on different versions of Chrome.
These agents all have chromedriver installed at /usr/local/share/chrome_driver
How do I force selenium-standalone-service to use the version of Chromedriver in this location? Happy to go from the command line or in the config. We're using typescript.

Related

Using VSCode WSL Remote, why won't Chrome Debugger launch Chrome for Windows?

I'm switching to VSCode WSL Remote mode for a JavaScript project. The Chrome Debugger Extension always look for Google Chrome in Linux. Is this the correct behavior?
I have a Chrome for Linux installed in WSL, which could run on X server. The problem is that the breakpoints are not working.
I've tried removing Chrome in WSL, the extension will then throw Can't find Chrome - install it or set the "runtimeExecutable" field in the launch config.
Should I set "runtimeExecutable" to chrome.exe or force it to run on local side with
"remote.extensionKind": {
"msjsdiag.debugger-for-chrome": "ui",
}
Could I correct some config so that the Chrome Debugger can find the Chrome in Windows if there's no Linux install?
Is there any official guide for it?
Thanks!
Yes, you should set
"remote.extensionKind": {
"msjsdiag.debugger-for-chrome": "ui"}
An alternative would be to set an alias chrome to go to chrome.exe in Windows. To ensure persistence, add it to your ~.bashrc or shell equivalent or alternatively .profile.
Side note: you should be able to debug with the new chromium-based Edge as well if you prefer using that.

Why doesn't ChromeDriver require Chrome or Chromium?

ChromeDriver is working on my system even though I don't have Chrome or Chromium installed. Based on the name, I thought it was like a "car driver" where you still need a car to get going. Or maybe like a product's API where you still need the product for your API calls to accomplish something.
Edit: Whoops, Chromium is installed after all.
Of course ChromeDriver requires Chrome or Chromium.
As per ChromeDriver - WebDriver for Chrome ChromeDriver is a separate executable that WebDriver uses to control Chrome.
Now, as per Requirements - ChromeDriver the server expects you to have Chrome installed in the default location for each system as follows:
1For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
You can also force ChromeDriver to use a custom location by setting a special capability. You can find the documentation in Using a Chrome executable in a non-standard location

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.

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.

Running Chrome WebDriver on a linux server with no display

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/