Can somebody tell me how to use the Chrome driver in Selenium for Linux platform?
I have my chrome driver location at username/home/chromedriver
.
My code is:
System.setProperty("webdriver.chrome.driver", "/home/username/ChromeDriver/chromedriver");
driver = new ChromeDriver();
driver.get("facebook.com");
The error I am getting is:
org.openqa.selenium.WebDriverException
: Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date.Using Chrome binary at:
/opt/google/chrome/google-chrome
(WARNING: The server did not provide any stacktrace information)
Finally, all you need to do is create a new ChromeDriver instance: WebDriver driver = new ChromeDriver(); driver. get("http://www.google.com"); Therefore, download the version of chromedriver you need, unzip it somewhere on your PATH (or specify the path to it via a system property), then run the driver.
In order for Chromedriver to work on Linux, you'll have to install Chrome binary. For Chromedriver version, it'll be dependent on your Chrome binary version.
Go to the terminal and type the command: sudo nano /etc/paths. Enter the password. At the bottom of the file, add the path of your ChromeDriver. Type Y to save.
From [the official documentation](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver:
Requirements
The ChromeDriver controls the browser using Chrome's automation proxy framework.
The server expects you to have Chrome installed in the default location for each system:
OS Expected Location of Chrome ------------------------------------- Linux /usr/bin/google-chrome Mac /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe Windows Vista C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
For Linux systems, the ChromeDriver expects
/usr/bin/google-chrome
to be a symlink to the actual Chrome binary. See also the section on overriding the Chrome binary location.Getting Started
To get set up, first download the appropriate prebuilt server. Make sure the server can be located on your
PATH
or specify its location via thewebdriver.chrome.driver
system property. Finally, all you need to do is create a new ChromeDriver instance:WebDriver driver = new ChromeDriver(); driver.get("http://www.google.com");
Therefore, download the version of chromedriver you need, unzip it somewhere on your PATH
(or specify the path to it via a system property), then run the driver.
We have installed Successfully
sudo apt-get install unzip
wget -N http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip -P ~/Downloads
unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads
chmod +x ~/Downloads/chromedriver
sudo mv -f ~/Downloads/chromedriver /usr/local/share/chromedriver
Change the directory to /usr/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
Now run the script and add the following in the environment file.
Capybara.register_driver :chrome do |app| client = Selenium::WebDriver::Remote::Http::Default.new Capybara::Selenium::Driver.new(app, :browser => :chrome, :http_client => client) end
Capybara.javascript_driver = :chrome
Note : Change the chrome driver version according to your operating system type like 32 bit or 64 bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With