[英]How to fix the org.openqa.selenium.WebDriverException: unknown error
While running the below code, I am observing org.openqa.selenium.WebDriverException: unknown error
exception. 运行以下代码时,我观察到
org.openqa.selenium.WebDriverException: unknown error
异常。
I am not able to understand why this error occurs even I am using simple driver initialization code. 即使使用简单的驱动程序初始化代码,我也无法理解为什么会发生此错误。
I am using Eclipse Mars 2. 我正在使用Eclipse Mars 2。
I used the following code: 我使用以下代码:
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
public class APP {
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "E:\\CDS\\Application\\chromedriver.exe");
try {
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e);
}
}
}
Returns this error 返回此错误
Please guide me to the way to fix it. 请引导我解决该问题。
It seems ChromeDriver
is not able to use default ChromeOptions
. 看来
ChromeDriver
无法使用默认的ChromeOptions
。 You can use below code to initialize the WebDriver
. 您可以使用以下代码初始化
WebDriver
。
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class APP {
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "E:\\CDS\\Application\\chromedriver.exe");
try {
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com");
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e);
}
}
}
Let me know the status, whether it works for you or not.
让我知道您的状态,不管它对您是否有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.