gpt4 book ai didi

java - ChromeDriver 启动 Chrome.app,但不驱动任何东西。我收到 : Could not start a new session

转载 作者:太空宇宙 更新时间:2023-11-04 13:23:41 26 4
gpt4 key购买 nike

这是我的代码:

public class App {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
WebDriver driver = new ChromeDriver();
driver.get("http://www.hepsiburada.com");

当我运行此代码时,Chrome 实际上会启动,但过了一会儿我得到:

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Build info: version: '2.47.2', revision: '4d972c01cab1304452627f837654326a11eb92fe', time: '2015-09-24 09:17:17' System info: host: 'Korays-MacBook-Pro.local', ip: '192.168.2.137', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.7.0_79'

有什么帮助吗?

最佳答案

您必须下载下载chromedriver binary对于您的平台,您必须在 System.setProperty 中提及。您提到的是chrome安装的位置,这是错误的。

根据 ChromeDriver以下是正确的做法

 // Optional, if not specified, WebDriver will search your path for chromedriver.
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

WebDriver driver = new ChromeDriver();

关于java - ChromeDriver 启动 Chrome.app,但不驱动任何东西。我收到 : Could not start a new session,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32849523/

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