gpt4 book ai didi

Selenium remoteWebDriver : connection to selenium-standalone-server fail (driver version unknown)

转载 作者:行者123 更新时间:2023-12-04 12:33:34 32 4
gpt4 key购买 nike

尝试通过在用Java编写的应用程序测试中使用remoteWebDriver设置与selenium-server-standalone的连接后,收到异常消息。

问题与使用remoteWebDriver通过使用Maven启动selenium-server-standalone(使用Xvfb)有关(因为通过不同的 session Xvfb手动运行,然后selenium-server独立运行应用程序测试有效)。
该环境由RH Linux R4.1.x,Selenium 2.1,firefox 3.6组成。 Selenium 服务器独立和应用程序测试都在同一台计算机(虚拟机)上执行。

如前所述,如果此实例是通过单独的PUTTY session (与用于启动应用程序测试的 session 分开)启动的,则该应用程序测试将成功连接到selenium-server-standalone-2.21.0实例:

#Xvfb :20 &
#export DISPLAY=:20
#Java –Dwebdriver.firefox.firefox=“/opt/firefox/firefox” –jar selenium-server-standalone-2-.21.0.jar -port 4441.

用于连接到selenium-server-standalone的应用程序测试代码如下:
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setPlatform(Platform.LINUX);
WebDriver driver = new RemoteWebDriver (new URL("http://127.0.0.1:14444/wd/hub"),capability);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

现在尝试在启动应用程序测试之前使用maven单独启动xvfb和selenium-server-stand,我得到以下错误(然后在同一腻子 session 中):
selenium server conenction string: http://127.0.0.1:14444/wd/hub
brand community file name orig :/opt/optism_svn/trunk/ITests/Projects/core/bbCampaigns/BrandCommunitiesWD/src/test/resources/Orig_BrandCommunity_Test6386.csv
before connecting to web driver
15:17:05.591 INFO - Executing: [new session: {platform=LINUX, browserName=firefox, version=}] at URL: /session)
15:17:05.651 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.18-194.el5', java.version: '1.6.0_22'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:158)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:112 )
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:89)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:92)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:62)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:202)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:597)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:548)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:520)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677)
at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.18-194.el5', java.version: '1.6.0_22'
**Driver info: driver.version: unknown**
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:68)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:52)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:197)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:184)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:151)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:58)
... 9 more
**Caused by: java.lang.IllegalStateException: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property**
at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:90)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
... 14 more
**15:17:05.659 WARN - Exception: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property**

以下是用于启动xvfb和selenium服务器的pom.xml(与零件相关的xvfb和selenium的摘录):
<properties>
<!-- Dependencies -->
<selenium-version>2.21.0</selenium-version>
<selenium-plugin-version>2.3</selenium-plugin-version>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium-version}</version>
</dependency>

.....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>${selenium-plugin-version}</version>
<configuration>
<background>true</background>
<port>14444</port>
</configuration>
<executions>

<execution>
<id>xvfb</id>
<phase>pre-integration-test</phase>
<goals>
<goal>xvfb</goal>
</goals>
….
<execution>
<id>start-selenium-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
</execution>

最佳答案

我昨天有同样的错误:

 Exception: The path to the chromedriver executable must be set by the  webdriver.chrome.driver system property**

我通过在节点计算机的路径中添加chromedriver.exe来解决该问题。 ( https://code.google.com/p/chromedriver/downloads/list)但是,如果尝试启动Firefox,就会出现此问题,这很奇怪。

关于Selenium remoteWebDriver : connection to selenium-standalone-server fail (driver version unknown),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15140045/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com