简体   繁体   English

如何修复org.openqa.selenium.WebDriverException:未知错误

[英]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.

相关问题 如何修复线程“主”org.openqa.selenium.WebDriverException 中的异常? - How to fix Exception in thread “main” org.openqa.selenium.WebDriverException? Selenium switchTo返回错误org.openqa.selenium.WebDriverException:未知错误:无法确定加载状态 - Selenium switchTo return error org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status org.openqa.selenium.WebDriverException:未知错误:无法使用ChromeDriver Selenium和Java聚焦元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element using ChromeDriver Selenium and Java org.openqa.selenium.WebDriverException:未知错误:无法通过Java用ChromeDriver Chrome和Selenium集中元素 - org.openqa.selenium.WebDriverException: unknown error: cannot focus element with ChromeDriver Chrome and Selenium through Java 线程“主”org.openqa.selenium.WebDriverException 中的异常:未知错误:使用 Selenium Java 的意外命令响应 - Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unexpected command response using Selenium Java org.openqa.selenium.WebDriverException:未知错误:chrome 无法通过 Java 开始使用 Selenium ChromeDriver 和 Chrome - org.openqa.selenium.WebDriverException: unknown error: chrome failed to start using Selenium ChromeDriver and Chrome through Java 获取错误:org.openqa.selenium.WebDriverException:未知错误:密钥应为字符串 - Getting error : org.openqa.selenium.WebDriverException: unknown error: keys should be a string 线程“主” org.openqa.selenium.WebDriverException中的异常:未知错误:无法聚焦元素 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: cannot focus element org.openqa.selenium.WebDriverException:未知错误:.net::ERR_CONNECTION_REFUSED - org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED 线程“ main” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:正常退出 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM