Android Studio使用chromedriver setProperty显示不存在

时间:2019-07-06 21:09:50

标签: android-studio selenium-webdriver

抱歉,这是我的第一篇文章 我已经尝试过“ C:\ chromedriver1.exe”“ C:/chromedriver1.exe”“ \ C:\ chromedriver1.exe”“ / C:/chromedriver1.exe”甚至尝试“ chromedriver1”也没有添加“ exe”但仍然显示关于 java.lang.IllegalStateException:驱动程序可执行文件不存在:...

我将chromedriver.exe放在C:

System.setProperty("webdriver.chrome.driver","C:\\chromedriver 1.exe");
ChromeOptions chromeOptions=new ChromeOptions();
                    chromeOptions.addArguments("--headless");
                    webDriver=new ChromeDriver();
                    webDriver.get("xxx.com");
                    String s=webDriver.getPageSource();

07-06 20:55:21.288 4214-4232/? W/System.err: java.lang.IllegalStateException: The driver executable does not exist: /C:\chromedriver 1.exe
07-06 20:55:21.289 4214-4232/? W/System.err:     at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:146)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
07-06 20:55:21.289 4214-4232/? W/System.err:     at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
07-06 20:55:21.289 4214-4232/? W/System.err:     at com.example.mygenius1willbeunderstood.TextFragment$1.run(TextFragment.java:71)
07-06 20:55:21.289 4214-4232/? W/System.err:     at java.lang.Thread.run(Thread.java:818)

0 个答案:

没有答案