java - 无法使用 Selenium 打开 Google Chrome Portable

标签 java google-chrome selenium portability

使用下面的代码尝试访问 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/

相关文章:

Java 8 部分函数应用/柯里化(Currying)

java - 如何使用 Spring Data Cassandra 从 cassandra 数据库读取超过百万条记录并使用 Spring Batch 将其写入文件?

java - 在 POM 中使用 By - Selenium

java - 扩展 JLabel 的类不遵循容器的布局

java - 计算大数的百分比

html - Chrome 不会根据 child 的内容展开 flex parent

vue.js - 弃用 - 网站从网络请求子资源,但由于其用户的特权网络位置而只能访问该子资源

javascript - Chrome 扩展程序注入(inject) Javascript 按钮更改页面

selenium - 获取 Appium 1.2 上的所有子元素

Python Selenium 右键单击