我正在尝试在Playframework 2.6.x上的Java中运行Selenium Webdriver测试功能,但无法正常工作,并且出现此错误
[错误]测试selenium.LoginTest.verfy1失败:org.openqa.selenium.WebDriverException:到达错误页面:about:neterror?e = connectionFailure&u = http%3A // localhost%3A9000 / login&c = UTF-8&f = regular&d = Firefox%20can%E2%80%99t%20建立%20a%20connection%20to%20the%20server%20at%20localhost%3A9000。 [错误]构建信息:版本:'3.14.0',修订版本:'aacccce0',时间:'2018-08-02T20:19:58.91Z' [错误]系统信息:主机:'amounaf-linux',ip:'192.168.43.220',os.name:'Linux',os.arch:'amd64',os.version:'4.4.0-137-generic ',java.version:'1.8.0_181' [错误]驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver [错误]功能{acceptInsecureCerts:true,browserName:firefox,browserVersion:62.0.3,javascriptEnabled:true,moz:accessibilityChecks:false,moz:geckodriverVersion:0.23.0,moz:headless:false,moz:processID:10464,moz :profile:/tmp/rust_mozprofile.BPQ58Q ...,moz:useNonSpecCompliantPointerOrigin:false,moz:webdriverClick:true,pageLoadStrategy:正常,平台:LINUX,platformName:LINUX,platformVersion:4.4.0-137-generic,rotatable:false ,超时:{隐式:0,pageLoad:300000,脚本:30000}} [错误]会话ID:92cb8b3f-1f1e-4319-8076-5064ba3a5ba8,耗时8.212秒 sun.reflect.NativeConstructorAccessorImpl.newInstance0(本地方法)处的[错误] sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)处的[错误] sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)处的[错误] java.lang.reflect.Constructor.newInstance上的[错误](Constructor.java:423) org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)出现[错误] org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)出现[错误] org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)出现[错误] org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)出现[错误] org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)出现[错误] org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)出现[错误] org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)出现[错误] selenium.LoginTest.setup(LoginTest.java:39)出现[错误] [错误]
这是我的代码 ` 公共类LoginTest {
@Inject
WebDriver driver;
@Inject
Application application;
@Inject
LoginPage login;
@Before
public void setup() throws InterruptedException {
application = new GuiceApplicationBuilder()
.withConfigLoader(env -> ConfigFactory.load(env.classLoader()))
.build();
Helpers.start(application);
System.setProperty("webdriver.gecko.driver", "/home/brabo/MyTools/geckodriver/geckodriver" + "");
driver = new FirefoxDriver();
driver.get("http://localhost:9000/login");
driver.wait(600);
}
@Test
public void verfy1() throws Exception {
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
login = new LoginPage(driver);
login.set_userName("admin@home.com");
login.set_password("test");
login.click_button();
(new WebDriverWait(driver, 50)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toString().contains("Connexion");
}
});
Assert.assertTrue(driver.getPageSource().contains("Action"));
}
@After
public void close() {
driver.close();
}
} `
感谢您的帮助:) :):)