Exception while connecting with Chrome driver - selenium

How to use Chrome Driver in selenium project? Here am using latest version of Chrome Driver. My code looks like:
System.setProperty("webdriver.chrome.driver", C:\\Users\\....\\Downloads\\chromedriver_win32_2.3.zip\\chromedriver.exe");
In 64 bit Windows 7, however I am getting an exception.
org.openqa.selenium.WebDriverException: unknown error: unable to
discover open pages
I searched in google they provide the solution to replace the latest version of Chrome driver. I tried but not able to solve the issue.

chromedriver_win32 supports both 32-bit and 64-bit machines.
Use the latest chromedriver version; Download it from,
http://chromedriver.storage.googleapis.com/index.html?path=2.9/
And add the below snippet in your code
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

Can you unzip chromedriver_win32_2.3.zip file and then provide location of ChromeDriver inside unzipped folder ... This should help. Modified code should look like the following:
System.setProperty("webdriver.chrome.driver", "C:\Users\....\Downloads\chromedriver_win32_2.3\chromedriver.exe");

Related

Chromedriver 107 for Mac M1

Need help or advice.
I can't find a chromedriver 107 for Mac M1. My current Chrome version 107, Selenium doesn't run tests.
Tried to install chromedriver_mac64.zip and chromedriver_mac_arm64.zip
I am using Mac M1 and with the following driver everything works:
https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_mac_arm64.zip
Third file from:https://chromedriver.storage.googleapis.com/index.html?path=107.0.5304.62/
Chrome is up to date
Version 107.0.5304.110 (Official Build) (arm64)
I suspect that the problem is related to configuration of the Selenium webdriver path or some security warning from macOS.
If you are hiting on the security warning, you can check this article on how to fix it:
https://thewiredshopper.com/apple-cannot-check-for-malicious-software-error/
System.setProperty("webdriver.chrome.driver", "/Users/myuser/Desktop/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/");

Fitnesse Browser tests , configuration for pointing to Chrome Binary in Linux [duplicate]

For compatibility reasons I prefer to use Chrome version 55.0.2883.75 with Chromedriver v. 2.26. I downloaded the older version of chrome from https://www.slimjet.com/chrome/google-chrome-old-version.php and Chromedriver 2.26 from https://chromedriver.storage.googleapis.com/index.html?path=2.26/.
I am using the following code to attempt to set my Chrome binary location:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)
However, when I attempt to launch the WebDriver Python returns the following error:
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
I have tried searching through similar questions and answers but have not had any luck so far. Any help is greatly appreciated - thank you in advance!
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The server expects you to have Chrome installed in the default location for each system:
OS
Expected Location of Chrome
Linux
/usr/bin/google-chrome1
Mac
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP
%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista and newer
C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
Using a Chrome executable in a non-standard location
However you can also override the default Chrome binary location as follows:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
Related Docs
Reference
You can find a detailed discussion in:
Is Chrome installation needed or only chromedriver when using Selenium?
What happened to me is that I didn't have chrome, the main browser, installed.
Download the browser and it fixes this issue.
Using an old version of chrome driver with the latest Google Chrome locally gave me the same exception.
Just go to the ChromeDriver page and make sure you have the latest version.
I faced similar issue in MacOS. Even after setting binary path in chromeoptions, it didn't work. It got fixed after installing npm i chromedriver
It is also important to download Chrome from the actual website. I ran into the same problem, but I had downloaded Chrome from the Ubuntu software package manager. I uninstalled the package manager version and installed from the website, and the error resolved. Same issue could probably arise installing from other package managers.
Check https://sites.google.com/a/chromium.org/chromedriver/getting-started
You can specify the binary path in the constructor of the webdriver:
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
I did this to solve my problem
private WebDriver driver;
#Before
public void StartBrowser() {
System.setProperty("webdriver.chrome.driver", "C://opt//WebDriver//bin//chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.saucedemo.com/");}
I have solved this problem by installing Google Chrome link and it solved problem automatically (I use Kali Linux) and be sure that it is installed to the "/usr/bin"(default it is downloaded to here).

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:

geb.driver.DriverCreationException: failed to create driver from callback

I am getting below Exception while running test scripts.
geb.driver.DriverCreationException: failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
java.lang.NoClassDefFoundError: Lorg/openqa/selenium/remote/html5/RemoteWebStorage;
failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
OS: Windows 10 64 bit
Chrome browser: v60 (latest one)
Selenium :-2.43.1
Chrome web driver:-2.24.417431
geb-version:0.10.0
geb-testng-version:0.13.1
geb-spoc-version:0.13.1
Thanks in Advance...!
This will be a version issue (your old web driver is not compatible with newer chrome versions). If you are using the latest version of chrome, I suggest moving to the latest version of selenium and chrome driver.
Infact one quick google suggests that I might be right: https://sites.google.com/a/chromium.org/chromedriver/downloads
Latest Release: ChromeDriver 2.31
Supports Chrome v58-60
This error can be thrown if you do not correctly define your chrome driver location when executing your tests.
Either in your GebConfig:
driver = {
System.setProperty('webdriver.chrome.driver', '/Users/foo/drivers/chromedriver')
new ChromeDriver()
}
Or in something like VM parameters if running from an intelliJ Run/Debug Configuration:
-Dbrowser=chrome -Dwebdriver.chrome.driver="/Users/foo/drivers/chromedriver/chromedriver.exe"
I was having this problem for a couple of days and finally understand the cause. This problem occurred for me on Jenkins when I am setting my browser to chrome or firefox and then trying to run my tests. It occurred due to browsers not installed on Jenkins machine. The drivers are present in the code but the browser should be installed on machine otherwise Geb will throw this error. Hope this helps.

how to use different version of firefox using webdriver?

how to set Firefox version in web-driver?
I just want to user different version of Firefox.
like different version 19, 20 , 21....
please provide a generic solution which help for other browser also.
You have to install all the versions on your system. Then you can use the System property webdriver.firefox.bin to define the path for Firefox. Note than since the path is set through a System property, you will not be able to run two different Firefox in the same Java process.
This solution is specific to Firefox. There is no generic solution. You have to configure every WebDriver yourself.
More information about the configuration of Firefox Web Drvier.
Finally i have found solution to run with different browser version
System.setProperty("webdriver.firefox.bin", "/Applications/Firefox-2.app/Contents/MacOS/firefox-bin");
WebDriver driver = new FirefoxDriver();
driver.get(baseUrl);
System.out.println(driver.getTitle());
driver.close();
driver.quit();
I have found how to start a different FireFox browser (actually WaterFox) in Python Selenium, replacing
driver = webdriver.Firefox()
with
driver = webdriver.Firefox(firefox_binary = "/path/to/my/waterfox")
(Ubuntu 20.04, Python 3.95)