【发布时间】: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