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

前端 未结 10 1618
攒了一身酷
攒了一身酷 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: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);
    

提交回复
热议问题