Getting “The path to the driver executable must be set by the webdriver.chrome.driver system property”though set correct path

前端 未结 10 1584
攒了一身酷
攒了一身酷 2020-12-10 11:30

My code is very simple code:

WebDriver wd =new ChromeDriver();
  System.setProperty("webdriver.chrome.driver",
                     "D:\\\\List         


        
相关标签:
10条回答
  • 2020-12-10 12:15

    The below lines works fine

    public class TestNGFile {
    
        public String baseUrl = "https://google.com";
        String driverPath = "C:\\\\Users\\\\Documents\\\\selenium\\\\chromedriver_win32\\\\chromedriver.exe";
        @Test
        public void verifyHomepageTitle() {
    
            System.out.println("launching chrome browser"); 
            System.setProperty("webdriver.chrome.driver", "C:\\Users\\Documents\\selenium\\chromedriver_win32\\chromedriver.exe");
            //System.setProperty("webdriver.gecko.driver", driverPath);
            WebDriver driver = new ChromeDriver();
            driver.get(baseUrl);
            String expectedTitle = "Google";
            String actualTitle = driver.getTitle();
            Assert.assertEquals(actualTitle, expectedTitle);
            driver.close();
    
    0 讨论(0)
  • 2020-12-10 12:15

    I faced the same issue. "The path to the driver executable must be set by the webdriver.chrome.driver system property." downloaded the driver and have set in system property.

    https://www.youtube.com/watch?v=Ny_8ikCbmcQ

    0 讨论(0)
  • 2020-12-10 12:17

    Driver path should be set before browser launch as given below.

    System.setProperty("webdriver.chrome.driver","D:\List_of_Jar\chromedriver.exe");
    WebDriver wd =new ChromeDriver();
    String baseUrl = "https://www.google.com";
    wd.get(baseUrl);"
    
    0 讨论(0)
  • 2020-12-10 12:19

    I also encountered the same problem. Following fix, made my application run smoothly.

    Firstly, the required version of chrome driver could be found from below link.

    http://chromedriver.storage.googleapis.com/index.html

    It is best to use always the latest version. After downloading, set the path of chrome driver in System.setProperty("webdriver.chrome.driver","{Your path Chrome Driver}");

    Follow the code fragment.

            System.out.println("Creating Chrome Driver");
         // Set Chrome Driver
            System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
    
            WebDriver driver = new ChromeDriver();
            driver.get("{Your URL}");
            System.out.println("Wait a bit for the page to render");
            TimeUnit.SECONDS.sleep(5);
            System.out.println("Taking Screenshot");
            File outputFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
            String imageDetails = "D:\\Images";
            File screenShot = new File(imageDetails).getAbsoluteFile();
            FileUtils.copyFile(outputFile, screenShot);
            System.out.println("Screenshot saved: {}" + imageDetails);
    
    0 讨论(0)
提交回复
热议问题