Did your Selenium WebDriver ChromeDriver just break? Here's how to fix it.
TL;DR: Add --remote-allow-origins=*
to the options for starting ChromeDriver temporarily. Wait for the next release of Selenium (probably 4.8.2) and then remove the option again.
- Author:
- Christian Hujer, CEO / CTO at Nelkinda Software Craft Pvt Ltd
- First Published:
- by
Nelkinda Software Craft Private Limited
- Last Modified:
- by Christian Hujer
- Approximate reading time:
![](WebDriverNotLoading.png)
Selenium Webdriver is a popular tool for testing web applications. Many teams are using it to test their web applications. The most popular Webdriver implementation probably is ChromeDriver.
And if that is your setup, then you might actually face a problem right now. ChromeDriver 111 is not compatible with the default HTTP Client. This means that your Selenium WebDriver tests are not working anymore.
As a workaround, you can add --remote-allow-origins=*
to the options for starting ChromeDriver. This will make ChromeDriver work again. But you should remove this option again as soon as possible. The next release of Selenium (probably 4.8.2) will fix this problem.
Here's an example for how this could look like in Kotlin:
@Component class WebDriverProvider { @Bean(destroyMethod = "quit") fun createDriver(): WebDriver = run { WebDriverManager.chromedriver().setup() val options = ChromeOptions() options.addArguments("headless") // See https://github.com/SeleniumHQ/selenium/issues/11750 // See https://github.com/bonigarcia/webdrivermanager/issues/1007 // See https://bugs.chromium.org/p/chromium/issues/detail?id=1422444 // Remove once Selenium is fixed. options.addArguments("remote-allow-origins=*") ChromeDriver(options) } }
The key is this line:options.addArguments("remote-allow-origins=*")
This line adds the option to the ChromeDriver. Note that this line is a workaround and should be removed as soon as possible. It is not a good idea to keep this option in your code. And if you can, replace the *
with a more specific URL.
Happy Testing!