gpt4 book ai didi

java - Selenium Chrome webdriver 异常

转载 作者:行者123 更新时间:2023-11-30 08:02:52 24 4
gpt4 key购买 nike

我正在尝试获取 Java 中的 webdriver 实例。我在后台运行了selenium。

    org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 121 milliseconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
System info: host: 'ARMac.home', ip: '192.168.1.5', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.3', java.version: '1.8.0_11'
Driver info: org.openqa.selenium.remote.RemoteWebDriver

我的代码如下

    System.setProperty("webdriver.chrome.driver", System.getProperty("user.home") + "/chromedriver");
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setJavascriptEnabled(true);
desiredCapabilities.setCapability("takesScreenshot", true);

String link = "http://www.google.com";
WebDriver driver = new RemoteWebDriver(new URL(
"http://127.0.0.1:4444/wd/hub"), desiredCapabilities);

我运行 Selenium 的方式是

java -jar selenium-server-standalone-2.46.0.jar -timeout=20

最佳答案

将 chrome webdriver 位置添加到您的 java 调用中:

java -jar selenium-server-standalone-2.46.0.jar -timeout=20 -Dwebdriver.chrome.driver=C:\path-to\chromedriver.exe

如果您决定也使用 IE 驱动程序,则需要添加它,例如:

-Dwebdriver.ie.driver=C:\IEDriverServer.exe 路径

关于java - Selenium Chrome webdriver 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31620350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com