Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

While executing selenium code using ProcessBuilder (java), I get the following error message:

Exception in thread "main" java.lang.ExceptionInInitializerError
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:62)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:87)
at org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(DriverCommandExecutor.java:80)
at org.openqa.selenium.chromium.ChromiumDriverCommandExecutor.<init>(ChromiumDriverCommandExecutor.java:35)
at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.<init>(ChromeDriver.java:118)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:106)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:93)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:48)
at SeleniumProto.main(SeleniumProto.java:7)
Caused by: java.lang.IllegalArgumentException: Unknown HttpClient factory netty
  at org.openqa.selenium.remote.http.HttpClient$Factory.create(HttpClient.java:57)
  at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:73)
  at org.openqa.selenium.remote.HttpCommandExecutor$DefaultClientFactoryHolder.<clinit>(HttpCommandExecutor.java:58)
  ... 9 more
Process finished with exit code 1

The selenium code is below:

   import org.openqa.selenium.chrome.ChromeDriver;
public class SeleniumProto {
    public SeleniumProto() {
    public static void main(String[] var0) {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\OneDrive\\Documents\\chromedriver.exe");
        ChromeDriver var1 = new ChromeDriver();
        var1.get("https://www.twitter.com");

There aren't many answers on the web on how to resolve this issue.

This code is working fine for me. Please ensure you have the ChromeDriver of proper version is installed in your system. You may also try to use WebDriverManager of Bonigarcia. – Ahamed Abdul Rahman Apr 23, 2022 at 17:16

It looks like a problem connected to selenium version or wrong webdriver version. Try with this:

    public static void main(String[] args) {
        WebDriverManager.chromedriver().setup();
        ChromeDriver driver = new ChromeDriver();
        driver.get("https://www.twitter.com");

Use the following depedencies:

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.6.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.3.1</version>
        </dependency>
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.