System hangs while using chromedriver 2.20 for chrome browser automation - google-chrome

I am using chromedriver 2.20 for chrome browser automation. But system hangs when the execution starts. Tried with chromedriver 2.19 also.
Driver initialization:
System.setProperty("webdriver.chrome.driver", rootDir+ "/resources/drivers/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().deleteAllCookies();
System Config:
Intel core i7 processor, 64bit OS, RAM: 16GB
Please suggest any solution.

Not facing any issue with below sample code on Win 7, 64-bit. Please share chromedriver log
System.setProperty("webdriver.chrome.driver","/path/to/chromedriver.exe"));
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
driver.manage().deleteAllCookies();
driver.get("http://www.google.com/");
System.out.println(driver.getTitle());

Related

org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 111 error with Selenium

I am sure that my tests are working correctly. When I run the code I got the error in terminal like,
Scenario: User adds new quick work order to employee from website # src/test/java/Features/5NewQuickJobOrder.feature:12
Starting ChromeDriver 111.0.5563.19 (378a38865270d286695aeb86f190564911ef7bc2-refs/branch-heads/5563#{#251}) on port 4290
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 111
Current browser version is 110.0.5481.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-CONJ3EC', ip: '192.168.1.27', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '19.0.2'
Driver info: driver.version: ChromeDriver
Recently Chrome updates itself and my version is now 110.0.5481.97. But somehow it tries the run the test with version 111 shows below. I have no version in my computer such that starts with 111..
Scenario: User adds new quick work order to employee from website # src/test/java/Features/5NewQuickJobOrder.feature:12
Starting ChromeDriver 111.0.5563.19 (378a38865270d286695aeb86f190564911ef7bc2-refs/branch-heads/5563#{#251}) on port 40758
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
I do not use any chromedriver exe in my project folder, I directly use setup and driver intsance.
public static WebDriver initialize_Driver(String browser) {
properties = ConfigReader.getProperties();
if (browser.equals("Chrome")) {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
#Before
public void before() {
String browser = Reporter.getCurrentTestResult().getTestContext().getCurrentXmlTest().getParameter("browser");
properties = ConfigReader.initialize_Properties();
driver = DriverCreater.initialize_Driver(browser);
}
I will be very glad, if you could help me!
First the solution
To instantiate a specific browser version of ChromeDriver you can use:
WebDriverManager.chromedriver().driverVersion("111.0.5563.19").setup();
Details
This error message...
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 111
...implies that SessionNotCreatedException was raised as ChromeDriver was unable to spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chrome=110.0.5481.97
But you are using chromedriver=111.0.5563.19
Release Notes of chromedriver=111.0 clearly mentions the following :
Supports Chrome version 111
So there is a clear mismatch between chromedriver=111.0 and the chrome=110.0
Solution
Ensure that:
ChromeDriver is downgraded to ChromeDriver v110.0 level.
Chrome Browser is updated to current chrome=110.0 (as per chromedriver=110.0 release notes).
Selenium is upgraded to current released Version 4.8.0.

Downgrade chromedriver version during runtime using webdrivermanager

Problem:
Facing an issue to downgrade chrome driver version during runtime.
Background:
Using chrome + Docan(needs chrome driver with v2.33) to do automation test of an application.
First, start chrome with driver version: 91.0.4472.124.
Then, switch to Docan which needs chrome driver with version 2.33.
Code:
WebDriverManager webDriverManager = null;
Initial:
webDriverManager = WebDriverManager.chromedriver();
Switch:
WebDriverManager.chromedriver().clearResolutionCache();
webDriverManager = WebDriverManager.chromedriver().driverVersion("2.33");
webdriver.avoidBrowserDetection();
Behavior:
After switch:
System.getProperty("webdriver.chrome.driver") --> return path for version 2.33
In log:
I could see chromedriver version is still 91
UI action:
Docan is not fully supported for actions like click.(It supports fine if driver is 2.33, tried with IE + Docan)
Is there any suggestion to make it work?

Unable to launch google chrome by selenium 3.4.1

I am using selenium version 3.4.0 and chrome version 59.xxx, Chrome driver version 2.30. Every time its shows error like-
Exception in thread "main" java.lang.NoSuchMethodError:
com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at
org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:111)
at
org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at
org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at
org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:302)
at
org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:124)
at SampleTesting.main(SampleTesting.java:8)
Below is my code-
System.setProperty("webdriver.chrome.driver", "D:\\Newfolder\\Selenium jars\\exe files\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("www.google.com");
Please help to resolve my query
thank you very much.
Check your Guava library version. An upgrade to 21.0 should resolve this issue.
Reference: https://github.com/SeleniumHQ/selenium/issues/3880

Chrome - org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension at driver.manage().window().maximize();

I am stuck with a very unusual kind of error thrown by Chrome Browser
When I try to do maximize chrome with below line of code
driver.manage().window().maximize();
I am getting below error
org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=57.0.2987.110)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.05 seconds
By going through this example I did the below things
1. Updated Chrome driver to latest i.e 2.28 for my Chrome version
57.0.2987.110 (64-bit)
2. uninstalled and re-installed Chrome
3. did a project build up in Eclipse even created a new workspace
but nothing helped so I used
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
driver = new ChromeDriver();
it worked and Chrome driver showed no error but whenever I execute some piece of code like filling a form or clicking some button after that it still throws the above error after some time.
In general the reason you see WebDriverException: unknown error: cannot get automation extension can be numerous. The two most common cases to see this exception is :
Mismatch between chromedriver binary and Chrome Browser binary versions. Solution : Follow the ChromeDriver Release Notes
Using driver.manage().window().maximize(); to maximize the Chrome Browser. Solution : Use ChromeOptions.addArguments("start-maximized"); to maximize the Chrome Browser.
As per your question the exception seems to be coming from one of the above cases.
Try out the following steps:
Kill all the chromedriver instances running in your windows Task Manager.
Use CCleaner tool to wipe out all the OS chores.
Clean all the projects in Eclipse.
Reboot your system once.
Provide the following options to start your Chrome browser:
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);
Your program should work with latest chrome driver 2.28 & Chrome Version 57.0.2987.110 (64-bit). Let me know if this helps you.
I had the same issue before, remember fixing it by adding this:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("no-sandbox");
//Fix for cannot get automation extension
chromeOptions.addArguments("disable-extensions");
chromeOptions.addArguments("--start-maximized");

Coded UI Test Selenium Chrome Driver

Selenium chromedriver;
The open chrome driver window displays:
Starting ChromeDriver (v2.8.241075) on port 10820
[8804:7492:0110/155544:ERROR:chrome_views_delegate.cc(176)] NOT IMPLEMENTED
[8804:7492:0110/155544:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED
[8804:7492:0110/155544:ERROR:desktop_root_window_host_win.cc(746)] NOT IMPLEMENTED
Windows 8
ChromeDriver 2.8
Selenium 2.39
Chrome version 32.0.1700.102 m
Coded UI Test;
BrowserWindow.CurrentBrowser = "chrome";
var browser = BrowserWindow.Launch(new Uri("http://www.google.com"));
...
To run a chrome driver refer below code.
You can download the driver from
http://chromedriver.storage.googleapis.com/index.html
Step 1 :
System.setProperty("webdriver.chrome.driver",driverPath+"\\chromedriver.exe");
Step 2
ChromeDriver driver = new ChromeDriver();
driver.get(YOUR_URL_HERE)
In C#, you have to write following code:
IWebDriver driver = new ChromeDriver("fullpath to chrome driver exe");
driver.Navigate().GoToUrl("http://www.google.com");
You can download the Chrome Driver from this URL:
https://sites.google.com/a/chromium.org/chromedriver/downloads
Change the url to https://www.google.com.
Right now you are using http://www.google.com