在使用Java编写的应用程序测试中使用remoteWebDriver尝试建立与selenium-server-standalone的连接后,我收到了一个异常.
问题是(因为由不同的会话的Xvfb,然后硒服务器独立的应用程序测试工作手动运行)相关remoteWebDriver的启动硒服务器独立(带的Xvfb)通过使用maven的使用.环境由RH Linux R4.1.x,Selenium 2.1,firefox 3.6组成.selenium-server-standalone和应用程序测试都在同一台机器(虚拟机)上执行.
如前所述,如果使用以下命令通过单独的PUTTY会话(与用于启动应用程序测试的会话分开)启动此实例,则应用程序测试将成功连接到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.
Run Code Online (Sandbox Code Playgroud)
连接到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);
Run Code Online (Sandbox Code Playgroud)
现在尝试使用maven在启动应用程序测试之前单独启动xvfb和selenium-server-stand我得到以下错误(然后在同一个putty会话中):
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 …Run Code Online (Sandbox Code Playgroud)