0

How do I install Selenium on Windows10 with WebDriver for Chrome? I didn't find a full tutorial for that and I keep getting this error:

enter image description here

And this Exception in Eclipse:

Exception in thread "main" org.openqa.selenium.chrome.FatalChromeException: Cannot create chrome driver
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.chrome.ChromeCommandExecutor.start(ChromeCommandExecutor.java:382)
    at org.openqa.selenium.chrome.ChromeDriver.startClient(ChromeDriver.java:65)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:85)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:25)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:43)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:53)
    at Priority_Automation.MyAutomation.main(MyAutomation.java:18)

This is the code:

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class MyAutomation {
    
    public static void main(String[] args)
    {
        //ChromeOptions options = new ChromeOptions();
        //options.addExtensions(new File("/path/to/extension.crx"));
        
        
        System.setProperty("webdriver.chrome.driver", 
  "C:\\Users\\user\\Desktop\\Selenuim\\chromedriver");
         ChromeDriver driver = new ChromeDriver();
        driver.get("www.google.com");
        System.out.println("Testing");
            
    }

}

Please assist.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

As you don't see any compilation errors, it seems installation of Selenium within Eclipse IDE or configuration of Selenium jars within Eclipse IDE have no issues.

However, as you are in environment within the System.setProperty() line you need to pass the absolute path of the ChromeDriver executable including the extension i.e. exe.

So effectively, your line of code will be:

System.setProperty("webdriver.chrome.driver", "C:\\Users\\user\\Desktop\\Selenuim\\chromedriver.exe");

Additionally, which invoking the url through get() you need to pass the complete url as:

driver.get("https://www.google.com/");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352