selenium 4x | issue in invoking chrome browser on windows

瀏覽次數:169 次
跳到第一則未讀訊息

Naini Ghai

未讀,
2022年11月28日 清晨7:12:192022/11/28
收件者:Selenium Users
Upgraded to Selenium 4.6.0, and the issue observed is that chrome is not getting invoked on windows. The same code is working fine on MAC.

pom.xml

        <dependency>
           <groupId>org.seleniumhq.selenium</groupId>
           <artifactId>selenium-java</artifactId>
           <version>4.6.0</version>
       </dependency>
       <dependency>
           <groupId>io.netty</groupId>
           <artifactId>netty-handler</artifactId>
           <version>4.1.85.Final</version>
       </dependency>

Code to invoke chrome:
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--ignore-certificate-errors");
        options.addArguments("--test-type");
        options.addArguments("--disable-extensions");
        options.addArguments("--disable-infobars");
        options.addArguments("--disable-save-password-bubble");
        options.addArguments("--enable-geolocation");
        options.addArguments("--start-maximized");
        options.addArguments("--disable-notifications");
        options.addArguments("--disable-component-update");
        // option to prevent crash due to DevToolsActivePort
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-dev-shm-usage");
        // suppress download pop-up
        options.addArguments("--safebrowsing-disable-download-protection");
        options.addArguments("--safebrowsing-disable-extension-blacklist");
        if (downloadPath != null) {
            // Setting new download directory path and download options
            Map<String, Object> prefs = new HashMap<String, Object>();
            prefs.put("download.default_directory", downloadPath);
            prefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", 1);
            prefs.put("download.prompt_for_download", false);
            prefs.put("safebrowsing.enabled", false);
            options.setExperimentalOption("prefs", prefs);
        }
        WebDriver driver = new ChromeDriver(options);

The above code is working fine on MAC and invoking chrome, but giving an issue in invoking Chrome on Windows.

Error observed:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are an invalid address of the remote server or browser start-up failure.

Caused by: org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.17763 x86_64)

The selenium-manager is bringing an old version of chrome driver (2.25.x) which is not compatible with Chrome 107.

As a workaround, can add the chrome driver path, but then we need to update the driver path every time the chrome version gets updated or have to suppress the chrome update, and that will be not in line with Selenum4x. As per Selenium4x, there is no need for a Bongarcia webdriver manager, as selenium-manager is now in-built, which should take care of the drivers, but unfortunately, it is giving an issue with Windows.

Selenium 4x with Edge is working fine on MAC as well as Windows.

Any help, with the above issue?

⇜Krishnan Mahadevan⇝

未讀,
2022年11月28日 清晨7:32:342022/11/28
收件者:seleniu...@googlegroups.com
Naini,

There's a very good chance that you perhaps hit a bug which would need to be fixed.

So I would suggest that you do the following:
  1. Setup a debug point for your execution on the windows machine in the method "org.openqa.selenium.manager.SeleniumManager#runCommand" and get hold of what all values are being passed.
  2. Include the details from (1) into a new bug report in https://github.com/SeleniumHQ/selenium/issues/new/choose

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2cb03fd9-f5ed-4f6e-a8c8-8f2269bf7cbdn%40googlegroups.com.

Naini Ghai

未讀,
2022年11月28日 上午8:19:062022/11/28
收件者:Selenium Users
Hi Krishnan,

On debug, it does not even go to "org.openqa.selenium.manager.SeleniumManager#runCommand". 

It raises exception at org.openqa.selenium.remote.RemoteWebDriver#startSession
       Response response = execute(DriverCommand.NEW_SESSION(singleton(capabilities)));
       .
       .
       Command command = new Command(sessionId, payload);

where command is holding
[null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--ignore-certificate-errors, --test-type, --disable-extensions, --disable-infobars, --disable-save-password-bubble, --enable-geolocation, --start-maximized, --disable-notifications, --disable-component-update, --no-sandbox, --disable-dev-shm-usage, --safebrowsing-disable-down..., --safebrowsing-disable-exte...], extensions: [], prefs: {download.default_directory: <path to download>, download.prompt_for_download: false, profile.content_settings.exceptions.automatic_downloads.*.setting: 1, safebrowsing.enabled: false}}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--ignore-certificate-errors, --test-type, --disable-extensions, --disable-infobars, --disable-save-password-bubble, --enable-geolocation, --start-maximized, --disable-notifications, --disable-component-update, --no-sandbox, --disable-dev-shm-usage, --safebrowsing-disable-down..., --safebrowsing-disable-exte...], extensions: [], prefs: {download.default_directory: <path-to-download-path>, download.prompt_for_download: false, profile.content_settings.exceptions.automatic_downloads.*.setting: 1, safebrowsing.enabled: false}}}}]

Message displayed on the console:
       Starting ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) on port 7366
       Only local connections are allowed.

Will raise a bug for the same.

Regards,
Naini

⇜Krishnan Mahadevan⇝

未讀,
2022年11月28日 上午8:35:102022/11/28
收件者:seleniu...@googlegroups.com
Have you tried finding out if there is any chromedriver already available in your system PATH?

I have a gut feel that there's an old chromedriver binary in your PATH, which selenium manager is ending up finding and so it perhaps is not downloading again.

Can you try doing a "which chromedriver" on WINDOWS, find out what version it is and maybe get rid of it and try again to see if selenium manager downloads the binary and the problem happens ?


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Naini Ghai

未讀,
2022年11月28日 上午9:09:492022/11/28
收件者:Selenium Users
Thanks, Krishnan, it worked. :)  Found one chromerdriver in the project path, so the selenium-manager was picking it up from there, instead of overriding it.

Regards,
Naini

回覆所有人
回覆作者
轉寄
0 則新訊息