javaselenium-webdriverselenium-chromedriverwebdriver-manager

WebDriverManager in an infinite loop when trying to launch a Chrome browser session


As part of upgrading program to the automation infrastructure, I've decided to remove Chrome driver exe from my project, and to implement a new approach to reduce the manual Chrome driver updates every time. I tried using WebDriverManager version 5.0.3, but unfortunately I got an error message that the chrome driver isn't compatible with browser 114 and up.

I tried to update both WebDriverManager and Selenium in my Maven POM file, and now the console is stuck in an infinite loop, without initiating a chrome browser session.

Line of code in Java:

WebDriverManager.chromedriver().clearDriverCache().setup();  

Also tried to specify my current Chrome browser version but no avail:

 WebDriverManager.chromedriver().browserVersion("124.0.6367.61").forceDownload().setup();

What can I do? I want the code to automatically handle Chrome driver in my local and on Jenkins runs, without manually downloading Chrome driver.

Versions used:

selenium 4.19.1
webdrivermanager 5.8.0
Chrome 124.0.6367.61 (updates regularly)
   

Solution

  • I cannot answer on the root cause of infinite loop, am afraid. However since you have mentioned the following line - "I want the code to automatically handle Chrome driver"

    I suggest you to utilise the new tool Selenium Manager built-in within the latest Selenium(v4.6.0 and above). You don't need WebDriverManager anymore, driver management will by done by selenium by itself. No need to set driver path manually nor there is need to use third party library such as WebDriverManager.

    Java code to launch google can be as simple as:

    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.com/");  
    }
    

    Few answers for your reference: