[英]Maven can't connect to remote standalone Selenium server
I am working on creating a test suite for a project at work, where we will be testing our application on several operating systems from a central box (all vms). 我正在为工作中的项目创建一个测试套件,在该套件中,我们将从一个中央盒(所有vm)的多个操作系统上测试我们的应用程序。 The box with the tests on is a CentOS server utilizing
apache-maven
for the tests. 带有测试框的是一台使用
apache-maven
进行测试的CentOS服务器。 I am trying to test against a Windows 10 box running selenium-standalone-server
but have had no luck so far. 我正在尝试针对运行
selenium-standalone-server
的Windows 10机器进行测试,但到目前为止还没有运气。 Here is the configuration for each box: 这是每个盒子的配置:
Sample Test 样品测试
package com.netsweeper.browsertests;
import static org.junit.Assert.assertEquals;
import java.net.URL;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.safari.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.support.ui.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class ReadyTest {
@Test
public void accessChrome() {
try {
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.4.60:4444/wd/hub"), DesiredCapabilities.chrome());
driver.get("http://google.com");
assertEquals("The page title should equal Google at the start of the test", "Google", driver.getTitle());
driver.close();
driver.quit();
}
catch ( java.net.MalformedURLException e) {
System.out.println("Broken");
}
}
}
Test Output 测试输出
[root@62 browser_tests]# mvn -Dtest=ReadyTest test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Browser Tests 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ browsertests ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /src/client_filter/browser_tests/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ browsertests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ browsertests ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /src/client_filter/browser_tests/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ browsertests ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ browsertests ---
[INFO] Surefire report directory: /src/client_filter/browser_tests/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.netsweeper.browsertests.ReadyTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.392 sec <<< FAILURE!
accessChrome(com.netsweeper.browsertests.ReadyTest) Time elapsed: 1.325 sec <<< ERROR!
org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 732 milliseconds
Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'
System info: host: '62.4.168.192.in-addr.arpa.support', ip: '192.168.4.62', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-642.1.1.el6.x86_64', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at com.netsweeper.browsertests.ReadyTest.accessChrome(ReadyTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Results :
Tests in error:
accessChrome(com.netsweeper.browsertests.ReadyTest): The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html(..)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.391 s
[INFO] Finished at: 2016-06-16T11:17:21-04:00
[INFO] Final Memory: 16M/168M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project browsertests: There are test failures.
[ERROR]
[ERROR] Please refer to /src/client_filter/browser_tests/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[root@62 browser_tests]#
C:\\Users\\------\\Documents\\client_filter\\selenium-server-standalone-2.53.0
C:\\Users\\------\\Documents\\client_filter\\selenium-server-standalone-2.53.0
java -jar selenium-server-standalone-2.53.0
from said directory java -jar selenium-server-standalone-2.53.0
C:\\Windows\\System32
C:\\Windows\\System32
C:\\Users\\Kendall Roth\\Documents\\client_filter> chromedriver.exe
However, the error above seems to indicate that the chromedriver is not in the right place to be found, even though it can be found from anywhere (due to being in path). 但是,以上错误似乎表明chromedriver不在正确的位置,即使可以从任何地方找到它也是如此(由于在路径中)。 The error was also displayed in the Windows console, and said the same thing.
该错误也显示在Windows控制台中,并表示相同的内容。
I have looked around, but can't find anything that deals with a remote install of the Selenium standalone server. 我环顾四周,但找不到任何与Selenium独立服务器的远程安装有关的内容。 This link unfortunately did not work, but was similar to my issue (albeit on a local scale): selenium-2-chrome-driver
不幸的是,此链接无效,但与我的问题类似(尽管在本地范围内): selenium-2-chrome-driver
As it turns out, it was a rather simple fix. 事实证明,这是一个相当简单的解决方案。 Although
C:\\Windows\\
is not in the system path this was where the chromedriver.exe
was supposed to go. 尽管
C:\\Windows\\
不在系统路径中,但这是chromedriver.exe
应该在的位置。 Placing it here instead of in C:\\Windows\\System32\\
appears to solve the problem. 将其放在此处而不是放在
C:\\Windows\\System32\\
似乎可以解决此问题。 I'm not sure if this is a remote server only thing or if it extends to local standalone instances as well, but this solution worked for us. 我不确定这是否仅是远程服务器,还是也可以扩展到本地独立实例,但是此解决方案对我们有用。
我发现在项目内的资源文件夹中包含chromedriver.exe是可行的故障保护,因此我不必依赖新的用户或远程服务器,该文件在文件系统中的正确位置具有可执行文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.