How to set up Selenium with Chromedriver on Jenkins-hosted Grid - selenium

I just make my frist steps with Selenium. I successfully set up a test (Firefox driver), running on Selenium grid on my Jenkins (using Jenkins-Selenium-Grid plugin). I also installed Chromdriver plugin and Chrome itself on the machine (Server2003 64bit) running Jenkins.
Chrome is installed for all users (in C:\Program Files (x86)\Google\Chrome\Application\chrome.exe). The Problem is: as soon i try to use the Chromedriver i get
UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Since the Firefox test runs fine it must be a problem with "browser start"?!
So the first question is: What is the default location for chrome binary that Chromdriver assumes?
Second Question: How to fix this? Is there an Einvironment Property to set? Or could i simply set PATH to chrome.exe' location.
UPDATE: i dug around a bit, ithink i ran into this or that. is the any workaround for this issues?

You can use this as a node setup code:
java -jar selenium-server-standalone-2.19.0.jar -Dwebdriver.chrome.driver="C:\Java\chromedriver.exe" -role node -hub http://localhost:4444/grid/register -browser "browserName=internet explorer,version=8,platform=WINDOWS" -browser "browserName=chrome,version=17,platform=WINDOWS" -browser "browserName=firefox,version=9,platform=WINDOWS" -browser "browserName=opera,version=11,platform=WINDOWS"
So there is direct point to chromedriver binary and it is a chromedriver.exe not the common chrome.exe. I had similar problem and it worked for me.

Just went through the same process myself.
Using Selenium Plugin you can set up the selenium grid.
Using Chromedriver Plugin you can have chrome driver automatically installed.
Using Selenium Axis Plugin you can create matrix jobs.
First time installation issue
After installing the Chromedriver plugin it can take a few minutes to download and be ready after it is automatically installed.
It can be that the slaves try and install the chromedriver before master is fully installed and so fail to lookup the download location.
Restarting the slaves will cause it to try again and install the chromedriver on the slaves.
On each slave and the master you should finally end up with a $JENKINS_HOME\tools\chromedriver\chromedrive.exe which you can refer to in the Jenkins Selenium plugin configuration for Chrome[driver] binary path as tools\chromedrive\chromedriver.exe and Jenkins will prepend the slave specific $JENKINS_HOME for you.
Installed Chrome to the default location which turned out to be C:\Program Files (x86)\Google\Chrome\Application\chrome.exe same as described.
At this point I could run a test job succesfully without the error you have shown.
DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("http://Jenkins.ip.here:4444/wd/hub"), capability);
driver.get(siteBase.toString());
String page = driver.getPageSource();
So some other things to consider
having changed jenkins selenium config, did you restart selenium service, after config change it appears to stop them. Does the config have instances specified.
if it was an install location issue, you might be able to change the install location options in the test cases using
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");

Did you specify the -Dwebdriver.chrome.driver=Path/To/ChromeDriver when starting your node?
Adding this may help.

I asked the same question in selenium group:
https://groups.google.com/forum/?fromgroups#!topic/selenium-users/-3LJ3wma3RE
the solution provided there didn't work for me but probably it works for you?
(set PATH for chromedriver on jenkins)

Related

ChromeDriver doesn't open in jenkins

I created a selenium cucumber framework that has a test.
The test needs to open chromeDriver, and it is working when I run it in my IDE without any problems.
When I run the project in Jenkins, although the test runs, the chromeDriver doesn't open at all.
The console log is:
17:32:14 Starting ChromeDriver 89.0.4389.23
(61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389#{#294})
on port 4816
17:32:14 Only local connections are allowed.
17:32:14 Please see
https://chromedriver.chromium.org/security-considerations for
suggestions on keeping ChromeDriver safe.
17:32:14 ChromeDriver was started successfully.
Of course, this log is shown in my ide with the difference that chromeDriver opens in IDE mode and doesn't open in Jenkins mode.
What can I do?
First of all you should add more description, like:
what language do you use?
how start driver in your code?
do you use local driver or remote one?grid or selenoid?
do you use --headless mode on jenkins?
does jenkins have Xs for running browser?
There's bunch of solving, but each of them is based on more particular description:
Best way, but a bit tricky/expensive:
launch own Grid/Seleloid server on ec2 instance on any cloud platform you like: GCP, AWS, Azure, DigitalOcean etc
install docker and launch selenoid intance
launch selenoid application by downloading from github release page:
chmod +x cm
./cm selenoid start --vnc
get its IP and provide it to your driver creation command
which looks like that:
java:
WebDriver driver = new RemoteWebDriver(new URL(SelenoidIP/wd/hub), firefoxOptions);
driver.get("http://www.google.com");
driver.quit();
ruby:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :remote, url: SelenoidIP/wd/hub
driver.get "http://www.google.com"
driver.close
python:
from selenium import webdriver
driver = webdriver.Remote(
command_executor=SelenoidIP/wd/hub)
driver.get("http://www.google.com")
driver.quit()
Update:
I found a better solution.
Start Jenkins as a process from command line, not as a service, to get Chrome to open.
https://stackoverflow.com/a/41457823/1691651
command line commands:
Jenkins.exe stop
java -jar Jenkins.war
To save your Jenkins configurations, create an Environment Variable for JENKINS_HOME that points to location listed on the "Configure Jenkins" setting.
Old answer:
This also happened to me in webdriver.io when using the "chromedriver" service. To solve it, I had to manually download the chromedriver at https://chromedriver.chromium.org/downloads and then run it via a terminal--I don't know why that fixed it.
I don't need to run chromedriver separately in a terminal when testing via command line on the same EC2 instance.

Jmeter WebDriver don't start

I tried to run WebDriver Sampler, but got problem with driver config.
First I tried to use Firefox Driver Config. When run only Firefox Driver Config (without any sampler) I see how Firefox launched but finally got error:
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7055; process output follows: ddons.json found.
Next I tried to use Chrome Driver config, but got error:
The driver executable does not exist.
I tried to solve the problem like this: How to solve this error an jmetere, but it doesn’t work.
Image with config and errors
With regards to Firefox you need to ensure that you use supported Firefox version. The latest JMeter WebDriver Plugin kg.apc:jmeter-plugins-webdriver:2.3 has transitive dependency on the selenium-firefox-driver:2.52.0 which means that you can use Firefox 45 or earlier with it.
Later Firefox versions will not work.
You can download Firefox 45 from Mozilla FTP website
More information: Q. How do I Know Which Browsers are Supported? chapter of The WebDriver Sampler: Your Top 10 Questions Answered guide
I found the tab with configuration path to driver
Picture with tab:

Unable to run WebDriverIo tutorial

I'm trying to follow the WebDriverIo tutorial at http://webdriver.io/guide.html .
After setting up the Selenium server, when I try executing the test node script (step 7 in the tutorial), selenium warns me of some errors (see screenshot for full log), and I don't get any output returned.
Steps to reproduce:
I start the Selenium server
When I try running the node script, this happens (clock to zoom):
At this point a Firefox window opens automatically, and remains blank.
I'm running Firefox v52 and Selenium 3.0.1. I downloaded Geckodriver from https://github.com/mozilla/geckodriver/releases
Any obvious thing that I'm missing? I'm very new to Selenium and browser automation, forgive the generic input :)
If you have been here to get your Windows release of gecko driver : https://github.com/mozilla/geckodriver/releases, you may have miss this message :
"IMPORTANT: If you use geckodriver with Selenium, you must upgrade to
Selenium 3.3 since this release aligns HTTP responses with the
WebDriver standard."
(I can see you are in v3.0.1).

Only local connections are allowed Chrome and Selenium webdriver

I am using Chrome webdriver 2.23 & Selenium 2.53.1.
I have tried a lot, but could not get it fixed. Whenever I run my selenium script, it is giving me the following error
Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 12162
Only local connections are allowed.
This is just an informational message. Your issue might be a missmatch between the versions of chromedriver and selenium-server-standalone.
Try with the latest selenium version 3.0, it is working for me.
Please not that for selenium 3.0 you need to specify the driver first and after the selenium server.
With the new selenium, which is 3.0 you should use:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium-server-standalone-3.0.0-beta2.jar
If you are using selenium version below 3.0 you need to reverse the order of selenium with the driver, like:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium_server.jar
When you are starting the selenium server, open a console in the directory with chromedriver and selenium server and execute the above command.
Here you are a working stack:
Some previous notes:
If you run selenium in a non graphical enviromnent, xvfb is required.
You will need selenium-server-standalone-2.53.1.jar (working version). You can download selenium versions here: http://selenium-release.storage.googleapis.com/index.html
You will also need chromedriver v 2.27. Download link: https://chromedriver.storage.googleapis.com/index.html
1) Run sudo Xvfb :10 -ac &
2) Run export DISPLAY=:10
3) Run java -jar "YOUR_PATH_TO/selenium-server-standalone-2.53.1.jar" -Dwebdriver.chrome.driver="YOUR_PATH_TO/chromedriver.2.27" -Dwebdriver.chrome.whitelistedIps="localhost"
First off, What you are seeing is not an error. It is an informational message.
When you run this driver, it will enable your scripts to access this and run commands on Google Chrome.
This can be done via scripts running in the local network (Only local connections are allowed.) or via scripts running on outside networks (All remote connections are allowed.). It is always safer to use the Local Connection option. By default your Chromedriver is accessible via port 9515.
See this answer if you wish to allow all connections instead of just local.
If your Chromedriver only shows the above two messages (as per the question), then there is a problem. It has to show a message like this, which says it started successfully.
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103#{#416}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
To troubleshoot this...
Step 1: Check your Chromedriver version
$ chromedriver --version
ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103#{#416})
My version is 83.0.4103.39.
Step 2: Check your Chrome Browser version
Open Google Chrome.
Options --> Help --> About Google Chrome
Or open a terminal and run the following command (works on Ubuntu).
$ google-chrome --version
Google Chrome 83.0.4103.61
My version is: Version 83.0.4103.61
Step 3: Compare versions of Chromedriver and Google Chrome
Both these versions are starting with 83, which means they are both compatible. Hence, you should see a message like below, when you run the below command.
$ chromedriver
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103#{#416}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
If your versions mismatch, then you will see the following message. You will not see the line which says, ChromeDriver was started successfully..
$ chromedriver
Starting ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987#{#882}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Step 4: Download the correct version of Chromedriver
Download the correct version that matches your browser version. Use this page for downloads. After you download, extract the content, and move it to one of the following two folders. Open each of the following two folders and see whether your current Chromedriver is there. If it is on both folders, replace both. And do STEP 3 again.
/usr/bin/chromedriver
/usr/local/bin/chromedriver
Check the version of your installed Chrome browser.
Download the compatible version of ChromeDriver from
https://sites.google.com/a/chromium.org/chromedriver/
Set the location of the compatible ChromeDriver to:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\your_path\\chromedriver.exe");
Run the Test again.
It should be good now.
You need to pass --whitelisted-ips= into chrome driver (not chrome!). If you use ChromeDriver locally/directly (not using RemoteWebDriver) from code, it shouldn't be your problem.
If you use it remotely (eg. selenium hub/grid) you need to set system property when node starts, like in command:
java -Dwebdriver.chrome.whitelistedIps= testClass etc...
or docker by passing JAVA_OPTS env
chrome:
image: selenium/node-chrome:3.141.59
container_name: chrome
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
- JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
I followed my frnd suggestion and it worked like a gem for me:
Working Code:
1) Downloaded chromedriver.
2) Code is
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Sel {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Downloads\\chromedriver_win32\\chromedriver.exe"); // path of chromedriver
WebDriver driver = new ChromeDriver();
driver.get("https://google.ca");
driver.manage().window().maximize();
driver.getTitle();
}
}
For me, updating the chromedriver and selenium version removed this message.
However, this is not an actual error and just an informational message.
If your program is still passing with exit code 0 at the end even when this message is printed, it means the execution went fine.
I was able to resolve the problem by following steps:
a. upgrade to the latest chrome version, clear the cache and close the chrome browser
b. Download latest Selenium 3.0
C#:
ChromeOptions options = new ChromeOptions();
options.AddArgument("C:/Users/username/Documents/Visual Studio 2012/Projects/Interaris.Test/Interaris.Tes/bin/Debug/chromedriver.exe");
ChromeDriver chrome = new ChromeDriver(options);
Worked for me.
Sorry for late post but still for info,I also facing same problem so I Used updated version of chromedriver ie.2.28 for updated chrome browser ie. 55 to 57 which resolved my problem.
I was also getting the same issue. I resolved this issue by updating the chromedriver. So if anyone is facing same issue with chrome browser just update your chromedriver.
I saw this error
Only local connections are allowed
And I updated both the selenium webdriver, and the google-chrome-stable package
webdriver-manager update
zypper install google-chrome-stable
This site reports the latest version of the chrome driver
https://sites.google.com/a/chromium.org/chromedriver/
My working versions are chromedriver 2.41 and google-chrome-stable 68

Jenkins with Xvfb and Selenium - Firefox started but nothing executed

I have a problem with Selenium under Jenkins 1.446 together with Xvfb: It looks like firefox is started correctly because I let my failing tests record screenshots. These screenshots all show the same failing page, which in my case is the starting page where the tests should begin. So I gues the selenium WebDriver commands do not arrive. What could be the reason? By the way, the tests are running perfectly on my local machine.
I'm using Firefox 9.0.1 with no specific test profile and no AddOns, Ubuntu 10.04, Senlenium 2.16.1
Log entry: com.thoughtworks.selenium.SeleniumException: Timed out waiting for action to finish
Thanks!
EDIT: Issue seems to be fixed by a system reboot ...
I experienced a very similar issue with FF9.0.1 and Selenium 2.16.1 running through JUnit launched by Maven SureFire plugin run by Jenkins on a WinXP node.
2.17.0 fixed the issue for me. Try updating to the latest Selenium.
Through RDP, I was able to watch the tests running. The tests appeared to be partially blocked by a prompt from Firefox asking about collecting anonymous usage statistics. Manually answering the prompt would allow the test to continue but because Selenium creates a new profile each time by default, the prompt would return on the next browser launch. Running the tests locally with a pre-configured FF profile allowed me to persist that the prompt had been answered. This isn't possible on my XP node because the tests are running as 'System'.
Selenium/WebDriver would normally take care of this for you by marking the prompt as already answered in a temporary FF profile configuration but a bug was causing the value to be set to the wrong value. You can inject a profile configuration to the Selenium FirefoxDriver driver to pragmatically configure stuff like this prompt but the bug appeared to prevent this as well. This has been resolved in Selenium 2.17.0 (http://selenium.googlecode.com/svn/trunk/java/CHANGELOG see 2.17.0 WebDriver bug fixes).