如果在另一篇文章中正在處理此主題,但我一直在尋找像兩天的解決方案,我無法獲得它。如何使用selenium-maven插件啓動chrome驅動程序來啓動Selenium服務器
我添加了一個新的配置文件到我的POM在whick我用硒 - Maven的插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<debug>true</debug>
<systemProperties>
<webdriver.chrome.driver>${webdriver.chrome}</webdriver.chrome.driver>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
他們在性能我已經加入其中chromedriver放置的路徑。
當我執行MVN全新安裝,我得到以下錯誤:
org.openqa.selenium.WebDriverException: org.openqa.selenium.net.UrlChecker.waitUntilAvailable(Ljava/net/URL;JLjava/util/concurrent/TimeUnit;)V
Command duration or timeout: 434 milliseconds
Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.6.0_51'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
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.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at com.qa.framework.drivers.multidevice.webdriver.MultiDeviceWebDriver.setWebDriver(MultiDeviceWebDriver.java:191)
at com.qa.framework.drivers.web.WebDriver.launchBrowser(WebDriver.java:249)
at com.qa.games.tests.BaseTest.beforeTestCase(BaseTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:640)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NoSuchMethodError: org.openqa.selenium.net.UrlChecker.waitUntilAvailable(Ljava/net/URL;JLjava/util/concurrent/TimeUnit;)V
at org.openqa.selenium.chrome.ChromeDriverService.start(ChromeDriverService.java:150)
at org.openqa.selenium.chrome.ChromeCommandExecutor.execute(ChromeCommandExecutor.java:48)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:432)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:140)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:95)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
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)
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)
... 3 more
如果相反的指示的webdriver有我的代碼添加的地方:System.setProperty("webdriver.chrome.driver", "/Users/support/Desktop/Google Chrome.app/Contents/MacOS/chromedriver.exe");
,然後返回了webdriver.chrome。驅動程序屬性未定義。
我也試過以及執行mvn clean install -Dwebdriver.chrome.driver="path/chromedriver"
以及返回相同的錯誤。
我已經嘗試在不同的路徑設置chromedriver,沒有.exe和.exe。
我不知道我在想什麼,即使我開始認爲這沒有任何解決方案,因爲如果我通過以下命令行執行我的硒測試:java -jar /path/selenium-server-standalone-2.37.0.jar -Dwebdriver.chrome.driver=/path/chromedriver"
,我的測試正在工作。如果硒正在運行或者不執行我的測試,我只是希望不會等待,但似乎這是不可能的。
如果有人能幫助我,我將不勝感激。
您是否設法使其工作? 如何? –