【问题标题】:Not able to automate Opera browser through Selenium WebDriver无法通过 Selenium WebDriver 自动化 Opera 浏览器
【发布时间】:2016-06-04 19:47:39
【问题描述】:

我正在自动化运行在 3 种浏览器(IE、Mozilla 和 Chrome)中的 Web 应用程序。

现在,当我尝试在具有不同功能的 Opera 中运行相同的代码时,它会打开 Opera 浏览器,但只有 URL 数据;显示并且我的测试没有运行。

这是我的示例代码:

DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
                System.setProperty("webdriver.opera.driver", "C:\\Important\\Test\\web\\src\\test\\resources\\operadriver.exe");
                driver = new OperaDriver(capabilities);
                driver.manage().window().maximize();

我收到以下错误:

org.openqa.selenium.WebDriverException: Opera not reachable   (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)

【问题讨论】:

    标签: selenium-webdriver automation opera webautomation


    【解决方案1】:

    请尝试

    DesiredCapabilities capabilities = DesiredCapabilities.opera();
    

    【讨论】:

    • 不走运。它正确地打开了浏览器,但它只显示数据:在 URL 中,没有进一步的测试正在运行。 Opera 似乎也过时了,它要求使用 operaBlink。
    • 能否请您尝试使用旧版本的 Selenium WebDriver java 文件
    • 我应该使用哪个版本?我目前使用的是 2.46。
    • 请从selenium下载页面下载并使用最新版本,最新版本为-selenium-java-2.53.0.jar
    • 下载了相同的,但问题仍然存在。收到此错误。 在端口 46805 上启动 OperaDriver 0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96) 只允许本地连接。
    【解决方案2】:

    我在 Windows 10、Selenium 3.5.2、Opera 52.0 和 OperaDriver 2.35 上进行了尝试,以下代码适用于我。

        DesiredCapabilities capablities=DesiredCapabilities.opera();
        System.setProperty("webdriver.opera.driver", "C:\\automation\\opera\\operadriver.exe");
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setBinary("C:\\Program Files\\Opera\\launcher.exe");
        capablities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
        OperaDriver driver = new OperaDriver(capablities);
        driver.get("https://www.google.com");
        driver.findElement(By.name("q")).sendKeys("how to use opera with selenium");    
    

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 2021-05-16
      • 2016-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      相关资源
      最近更新 更多