简体   繁体   中英

Could not able to launch chrome browser using the selenium webdriver

import org.openqa.selenium.chrome.ChromeDriver;

public class launch {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ChromeDriver driver = new ChromeDriver();
        driver.get("https://www.google.com/");
    }
}

Error:

Could not find or load main class org.openqa.grid.selenium.GridLauncherV3

In the Launch class you are directly creating the object of ChromeDriver class without giving the chrome driver path. So, before creating the ChromeDriver object you need to add:

System.setProperty("webdriver.chrome.driver","path of chromedriver.exe file");

If you have downloaded the chrome driver exe file then you need to pass that path. After this create the object of ChromeDriver class.

You need to set the system property webdriver.chrome.driver as follows:

System.setProperty("webdriver.chrome.driver", '/path/to/chromedriver');

Additionally, instead of using the ChromeDriver use the WebDriver interface as follows:

WebDriver driver = new ChromeDriver();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM