使用下面的代码尝试访问 google chrome 可移植浏览器。
System.setProperty("webdriver.chrome.driver","C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe");
driver=new ChromeDriver();
浏览器打开但立即关闭,出现以下异常
异常:
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.
任何人都可以帮助我如何使用 Selenium Webdriver 访问 Google Chrome 可移植浏览器。
最佳答案
下面的代码成功调用了 Google Chrome 可移植浏览器。
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Selenium\\Browsers\\GoogleChromePortable\\GoogleChromePortable.exe");
System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe");
driver = new ChromeDriver(options);
关于java - 无法使用 Selenium 打开 Google Chrome Portable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37295381/