2017-06-16 49 views
0

我已經更新了我的pom.xml文件中WebDrivermanager的依賴關係。 同時在我的本地運行下面的代碼似乎工作正常。webdrivermanager是否支持RemoteWebDriver(Selenium Grid)?

driver = new ChromeDriver(capability); 

但是當我試圖用RemoteWebDriver遠程運行代碼,它失敗了,不斷地問加二進制文件瀏覽器

URL remote_grid = new URL("http://" + seleniumHub + ":" + seleniumHubPort + "/wd/hub"); 
driver = new RemoteWebDriver(remote_grid, capability); 

它拋出異常下面。

[Invoker 1386767190] Keeping method SeleniumInit.setUp(java.lang.reflect.Method, org.testng.ITestContext)[pri:0, instance:[email protected]] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex] 
[Invoker 1386767190] Keeping method SeleniumInit.tearDown(org.testng.ITestResult)[pri:0, instance:[email protected]] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex] 
[Invoker 1386767190] Keeping method SeleniumInit.setUp(java.lang.reflect.Method, org.testng.ITestContext)[pri:0, instance:[email protected]] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex] 
[Invoker 1386767190] Invoking @BeforeMethod SeleniumInit.setUp(java.lang.reflect.Method, org.testng.ITestContext)[pri:0, instance:[email protected]] 
13:27:40.503 [main] INFO i.g.bonigarcia.wdm.BrowserManager - Reading https://chromedriver.storage.googleapis.com/ to seek [chromedriver] 
13:27:41.358 [main] INFO i.g.bonigarcia.wdm.BrowserManager - Latest version of [chromedriver] is 2.30 
13:27:41.368 [main] DEBUG io.github.bonigarcia.wdm.Downloader - Using binary driver previously downloaded C:\Users\zara\.m2\repository\webdriver\chromedriver\win32\2.30\chromedriver.exe 
13:27:41.368 [main] INFO i.g.bonigarcia.wdm.BrowserManager - Exporting webdriver.chrome.driver as C:\Users\zara\.m2\repository\webdriver\chromedriver\win32\2.30\chromedriver.exe 
========= Google Chrome Browser ========== 
Failed to invoke configuration method com.wo2.init.SeleniumInit.setUp: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: 120 milliseconds 
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' 
System info: host: 'ICWS-1162', ip: '192.168.0.42', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111' 
Driver info: driver.version: RemoteWebDriver 
[Invoker 1386767190] Keeping method SeleniumInit.tearDown(org.testng.ITestResult)[pri:0, instance:[email protected]] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex] 
[Invoker 1386767190] Invoking @AfterMethod SeleniumInit.tearDown(org.testng.ITestResult)[pri:0, instance:[email protected]] 

TEST FAILED - validLogin 

ERROR MESSAGE: null 


message from tear downjava.lang.NullPointerException 
===== Invoked methods 
    SeleniumInit.fetchSuiteConfiguration(org.testng.ITestContext)[pri:0, instance:[email protected]][email protected] 1501587365 
    LoginIndex.validLogin()[pri:0, instance:[email protected]] 1501587365 
===== 
Creating D:\Rahul_P-QA\Intech_Workspace\WO2_QA\WO2_QA\test-output\Work Order - 2\WO2_SC_001 _ To verify user can login successfully..html 
Creating D:\Rahul_P-QA\Intech_Workspace\WO2_QA\WO2_QA\test-output\Work Order - 2\WO2_SC_001 _ To verify user can login successfully..xml 
FAILED CONFIGURATION: @BeforeMethod setUp(public void com.wo2.commonfucntion.index.LoginIndex.validLogin(), [email protected]) 
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: 120 milliseconds 
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' 
System info: host: 'ICWS-1162', ip: '192.168.0.42', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111' 
Driver info: driver.version: RemoteWebDriver 

回答

0

實際上,WebDriverManager可以幫助您設置Selenium Grid。該過程如下:

  1. 啓動集線器。您可以使用命令行(java -jar selenium-server-standalone-<version>.jar -role hub)或使用類似於此example的Java類來完成此操作。
  2. 集線器中的寄存器節點。這裏是WebDriverManager的幫助,因爲它下載適當的二進制文件,註冊該二進制文件。在這裏你可以找到一個使用Chrome瀏覽器的example
  3. 運行測試,連接到URL的中心。這裏另一個example
+0

很酷,明白了,感謝Boni的幫助。 – promitheus

+0

如果它對你有用,你應該檢查答案是否被接受 –