gpt4 book ai didi

java - webdrivermanager 是否支持 RemoteWebDriver (Selenium Grid)?

转载 作者:行者123 更新时间:2023-12-05 09:18:24 25 4
gpt4 key购买 nike

我已经在我的 pom.xml 文件中更新了 WebDrivermanager 的依赖项。在我的本地运行代码时,如下所示,它似乎工作正常。

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:com.wo2.commonfucntion.index.LoginIndex@598067a5] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex]
[Invoker 1386767190] Keeping method SeleniumInit.tearDown(org.testng.ITestResult)[pri:0, instance:com.wo2.commonfucntion.index.LoginIndex@598067a5] 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:com.wo2.commonfucntion.index.LoginIndex@598067a5] 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:com.wo2.commonfucntion.index.LoginIndex@598067a5]
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:com.wo2.commonfucntion.index.LoginIndex@598067a5] for class [TestClass name=class com.wo2.commonfucntion.index.LoginIndex]
[Invoker 1386767190] Invoking @AfterMethod SeleniumInit.tearDown(org.testng.ITestResult)[pri:0, instance:com.wo2.commonfucntion.index.LoginIndex@598067a5]

TEST FAILED - validLogin

ERROR MESSAGE: null


message from tear downjava.lang.NullPointerException
===== Invoked methods
SeleniumInit.fetchSuiteConfiguration(org.testng.ITestContext)[pri:0, instance:com.wo2.commonfucntion.index.LoginIndex@598067a5]org.testng.TestRunner@485e36bc 1501587365
LoginIndex.validLogin()[pri:0, instance:com.wo2.commonfucntion.index.LoginIndex@598067a5] 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(), org.testng.TestRunner@485e36bc)
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

最佳答案

事实上,WebDriverManager 可以帮助设置 Selenium Grid。流程如下:

  1. 启动集线器和节点。您可以使用命令行 ( java -jar selenium-server-standalone-<version>.jar standalone ) 执行此操作,或在 WebDriverManager 的帮助下使用 Java 类来下载适当的驱动程序。在这里你可以找到一个 example使用 Chrome 和 Firefox 作为浏览器。
  2. 运行您的测试,连接到 URL 的中心。这里还有一个example .

关于java - webdrivermanager 是否支持 RemoteWebDriver (Selenium Grid)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44584033/

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