java - Selenium webdriver 正在查看 Chrome.exe 的错误路径
问题描述
我正在尝试从 selenium webdriver 启动 chrome.exe 我已经在我的机器上安装了 chrome 并且 chromedriver 路径也在代码中给出但是 selenium webdriver for java 正在寻找错误路径上的 chrome.exe 并给出错误并且不启动浏览器。
我已经尝试使用选项类来使用 chrome.exe 的实际路径定位 chrome.exe,但对我不起作用。我也完成了必需的导入,但仍然没有成功。
我试过下面的 selenium webdriver java 代码
public class News24Test
{
public static void main(String[] args) throws Exception
{
System.setProperty("webdriver.chrome.driver","C://News24SA//ChromeDriver//chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C://Program Files(x86)//Google//Chrome//Application//chrome.exe"); // Provide absolute executable chrome browser path with name and extension here
WebDriver driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("http://www.news24.com");
}
}
Selenium 正在查看以下路径,这是错误的路径 C:\Users\orestip\LocalSettings\Application Data\Google\Chrome\Application\chrome.exe
解决方案
先尝试设置选项:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\News24SA\\ChromeDriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
推荐阅读
- photoshop - Photoshop脚本获取图像层变换信息
- c# - 在字符串中查找选择器,并根据 X 选择器编辑字符串
- angular - 如何有效管理表单上的两类控件?
- python - 熊猫忽略非日期值
- postgresql - Heroku/Postgres:引起:java.net.ConnectException:连接被拒绝(连接被拒绝)
- awk - 如何呈现多个 grep,就好像它们在不同的列中一样?
- python - 试图做一个合并。处理由递增数字组成的标题的最佳方法是什么?
- git - 致命:--author 'First Last example@example.com' 不是 'Name
' 并且不匹配现有作者 - r - 在 R 中使用 dplyr 创建频率数据框
- flutter - Audience Network - 涉嫌捆绑和展示位置违规的申诉限制为 3 次