java Chrome 浏览器未在 selenium webdriver 中打开
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39343001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Chrome browser is not opening in selenium webdriver
提问by Saurabh Shrivastava
My code is not launching browser.
Project show running for a long time, but nothing happens. I pushed print and observed that WebDriver driver = new ChromeDriver();
is not getting executed.
我的代码没有启动浏览器。
项目表演运行了很长时间,但没有任何反应。我按下打印并观察到它WebDriver driver = new ChromeDriver();
没有被执行。
package seleniumautomation;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class seleniumautomation {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:/selenium_java/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://www.zaakpay.com/");
}
}
After some debugging, I am getting this new error:
经过一些调试后,我收到了这个新错误:
I added manifest_vesion, but in every run, it is generating a new file and i am again getting same error.
我添加了 manifest_vesion,但在每次运行时,它都会生成一个新文件,我再次遇到相同的错误。
回答by KishoreReddy
Download jar from: http://chromedriver.storage.googleapis.com/index.html?path=2.23/
从以下位置下载 jar:http: //chromedriver.storage.googleapis.com/index.html?path=2.23/
System.setProperty("webdriver.chrome.driver",
"<Downloaded file location>");
WebDriver driver = new ChromeDriver();
driver.get("https://www.zaakpay.com/");
Then, it will work.
然后,它将起作用。
回答by Eddie Singh
To use Chrome Browser needs to System.setPropert("webdriver.chrome.driver","PATH")
要使用 Chrome 浏览器需要 System.setPropert("webdriver.chrome.driver","PATH")
The ChromeDriver is maintained / supported by the Chromium project iteslf. WebDriver works with Chrome through the chromedriver binary.
ChromeDriver 由 Chromium 项目 iteslf 维护/支持。WebDriver 通过 chromedriver 二进制文件与 Chrome 一起使用。
Download Link of ChromeDriver : LINK
ChromeDriver 的下载链接 : LINK
回答by Priyanka Chaturvedi
You need to add chromedriver.exe(can be downloaded from http://www.seleniumhq.org/download/) to your project. Along with it, you need to add following lines in your code:
您需要将 chromedriver.exe(可以从http://www.seleniumhq.org/download/下载)添加到您的项目中。除此之外,您还需要在代码中添加以下几行:
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
capabilities= DesiredCapabilities.chrome();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
回答by Amanpreet Kaur
Use following code snippet to launch chrome driver.
使用以下代码片段启动 chrome 驱动程序。
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
ChromeOptions opt = new ChromeOptions();
opt.addArguments("disable-extensions");
opt.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(opt);
回答by Sina Cengiz
I solved the issue by changing my OS windows 10 language to english. selenium methods can not execute some other languages. If in both IE, geckodriver and chrome you are having the same issue it is language problem I can asuure you
我通过将操作系统 Windows 10 语言更改为英语解决了该问题。selenium 方法不能执行其他一些语言。如果在 IE、geckodriver 和 chrome 中你都遇到同样的问题,那就是语言问题,我可以向你保证