【问题标题】:Win10 supports selenium3.0.1?Win10支持selenium3.0.1?
【发布时间】:2017-04-29 18:29:57
【问题描述】:

selenium-server-standalone-3.0.1.jar 是否与 Windows 10 操作系统兼容?

我能够运行一个简单的 java 程序,在启动 Firefox 浏览器时出现以下错误。尝试使用 TestNG,但遇到同样的问题

代码:

package com.riversad.violet;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class DemoTests {
    public void sampleTest1(){
        System.setProperty("webdriver.gecko.driver", "D:\\Auto Violet Work Space\\VioletAutomation\\lib\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.gmail.com");
    }
    public void tests() {
        System.out.println("hellow world");
    }
    public static void main(String[] args) {
        DemoTests dt=new DemoTests();
        dt.sampleTest1();
        dt.tests();
    }
}

错误:

线程“main”中的异常 java.lang.NoSuchFieldError: INSTANCE 在 org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:144) 在 org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71) 在 org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:57) 在 org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:60) 在 org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:250) 在 org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.(ApacheHttpClient.java:227) 在 org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:92) 在 org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:71) 在 org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:59) 在 org.openqa.selenium.remote.service.DriverCommandExecutor.(DriverCommandExecutor.java:49) 在 org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:247) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:242) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:238) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:127) 在 com.riversad.violet.DemoTests.sampleTest1(DemoTests.java:25) 在 com.riversad.violet.DemoTests.main(DemoTests.java:41)

【问题讨论】:

  • 1.是的,windows 10 支持 selenium 3.0.1 2. 从你的代码中我可以看到,你只使用 WebDriver API,所以你不需要 selenium-server - docs.seleniumhq.org/docs/03_webdriver.jsp 3. 向我们展示你在这里粘贴的代码的异常,因为现在我们不能查看哪些代码行导致异常
  • 异常在“WebDriver driver = new FirefoxDriver();”中被捕获
  • 你用什么来构建你的项目?马文? Gradle?java.lang.NoSuchFieldError 通常会抛出一些依赖项,在不同版本中包含不止一次。请参阅:stackoverflow.com/questions/22330848/…stackoverflow.com/questions/27921077/…
  • 我没有使用 Maven 或 Gradle。我只是去项目 - >清洁。希望这将建立我的项目。我正在使用带有 Selenium 3.0.1 jar 文件的最新 firefox 和 chrome 版本
  • 您是否使用任何其他外部库?

标签: selenium-grid


【解决方案1】:

在我的 Windows 10 机器上使用带有 selenium 3.0.1 的 webdriver 时,我遇到了类似的问题。

从 [Selenium Downlaod][1] 下载旧版本的 selenium webdriver。 从下载的 zip 文件中搜索 jcommander-1.48.jar 并将此 jar 添加到您当前的项目中。

这应该会修复 NoSuchFieldError 并且您的项目应该可以成功编译。

【讨论】:

    猜你喜欢
    • 2017-08-21
    • 1970-01-01
    • 2022-12-30
    • 2022-12-20
    • 1970-01-01
    • 2013-10-03
    • 2012-04-15
    • 2018-04-08
    • 1970-01-01
    相关资源
    最近更新 更多