当前位置: 首页 > 知识库问答 >
问题:

无法实现selenium网格

祖奇
2023-03-14

下面是我的代码,我正在使用它来传递浏览器、节点和枢纽港来启动浏览器并执行测试,但是我得到了异常,尽管我能够设置selenium服务器。我把错误贴在代码下面。我使用mac book、Selenium3.4、Firefox55和Gecko0.18.0

public synchronized WebDriver setUp(String browser, String 
nodePort, String hubPort) throws MalformedURLException{

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setPlatform(Platform.MAC);
capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
capabilities.setCapability(ForSeleniumServer.PROXYING_EVERYTHING, 
true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_ALERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, 
true);

if(browser.equals("firefox"))
    System.setProperty("webdriver.gecko.driver", 
System.getProperty("user.dir")+"//geckoDriver//geckodriver");
else if(browser.equals("chrome"))
    System.setProperty("webdriver.chrome.driver", 
System.getProperty("user.dir")+"//chromeDriver//chromeDriver");
driver = new RemoteWebDriver(new 
URL("http://localhost:"+nodePort+"/wd/hub"), capabilities);
driver.get("https://www.bookbaby.com");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
System.out.println(driver.toString());
return driver;

下面是命令提示符中的日志

13:25:14.249 INFO - Selenium build 
info: version: '3.4.0', revision: 'unknown'
13:25:14.249 INFO - Launching a Selenium Grid node
2017-09-12 13:25:14.814:INFO::main: Logging initialized @833ms to 
org.seleniumhq.jetty9.util.log.StdErrLog
13:25:14.864 INFO - Driver provider 
org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, 
browserName=internet explorer, version=, platform=WINDOWS}] does not 
match the current platform MAC
13:25:14.864 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver 
registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, 
version=, platform=WINDOWS}] does not match the current platform MAC
13:25:14.864 INFO - Driver class not found: 
com.opera.core.systems.OperaDriver
13:25:14.864 INFO - Driver provider com.opera.core.systems.OperaDriver 
registration is skipped:
 Unable to create new instances on this machine.
13:25:14.865 INFO - Driver class not found: 
com.opera.core.systems.OperaDriver
13:25:14.865 INFO - Driver provider com.opera.core.systems.OperaDriver 
is not registered
2017-09-12 13:25:14.899:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-09-12 13:25:14.938:INFO:osjsh.ContextHandler:main: Started 
o.s.j.s.ServletContextHandler@e056f20{/,null,AVAILABLE}
2017-09-12 13:25:14.963:INFO:osjs.AbstractConnector:main: Started 
ServerConnector@39529185{HTTP/1.1,[http/1.1]}{0.0.0.0:5556}
2017-09-12 13:25:14.963:INFO:osjs.Server:main: Started @982ms
13:25:14.963 INFO - Selenium Grid node is up and ready to register to 
the hub
13:25:14.983 INFO - Starting auto registration thread. Will try to 
register every 5000 ms.
13:25:14.983 INFO - Registering the node to the hub: 
http://localhost:4445/grid/register
13:25:15.044 INFO - The node is registered to the hub and ready to use
13:25:20.205 INFO - SessionCleaner initialized with 
 insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 
180000
13:26:11.724 INFO - Executing: [new session: Capabilities 
[{proxyEverything=true, acceptSslCerts=true, marionette=true, 
acceptInsecureCerts=true, browserName=firefox, javascriptEnabled=true, 
handlesAlerts=true, version=, platform=MAC}]])
13:26:11.738 INFO - Creating a new session for Capabilities 
[{proxyEverything=true, acceptSslCerts=true, marionette=true, 
acceptInsecureCerts=true, browserName=firefox, javascriptEnabled=true, 
handlesAlerts=true, version=, platform=MAC}]
13:26:11.770 WARN - Exception thrown
java.util.concurrent.ExecutionException: 
org.openqa.selenium.WebDriverException: 
java.lang.reflect.InvocationTargetException
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'XXXXXX-MacBook-Pro.local', ip: '192.168.108.206', 
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', 
java.version: '1.8.0_144'
Driver info: driver.version: unknown

13:26:11.777 WARN - Exception: The path to the driver executable must 
be set by the webdriver.gecko.driver system property; for more 
information, see https://github.com/mozilla/geckodriver. The latest 
version can be downloaded from 
https://github.com/mozilla/geckodriver/releases

共有1个答案

顾俊誉
2023-03-14

请在计算机中设置环境变量webdriver.gecko.driver及其值。

也可以在启动集线器或注册节点时传递参数webdriver.gecko.driver。就像

java -Dwebdriver.gecko.driver="path to the gecko driver" {jar} -role node/hub
 类似资料:
  • null V: BrowserTimeout:0 调试:false DownPollingLimit:2 集线器:http://jenkins主机:jenkins端口 ID:http://node ip:node端口 null 异常的第一行说它无法解析某些东西,但我不能理解什么? 我是不是漏掉了什么?我是第一次做网格设置。

  • 我希望我的程序打开默认的chrome配置文件,然后获得YouTube。我可以让它打开youtube(在新的chrome浏览器中),或者打开默认的chrome配置文件,但不能两者兼而有之。(不,我没有运行两个驱动变量) 当我运行获取chrome配置文件的驱动程序行时,我会得到错误: 回溯(最近的调用为last):文件“C:\users\myname\onedrive\documents\python

  • 升级到最新的selenium后,Selenium网格给出了注册请求()的错误。我req.set角色()、req.set配置()等找不到。看起来像是注册请求()类在selenium新版本中得到了改变,但不确定如何使用该类并修改我现有的代码。知道如何解决这个问题吗? 这是我的密码,

  • 我想用机器人框架实现selenium网格。我已经配置了selenium网格集线器和两个节点,但是我不知道如何在此设置后触发并行测试用例执行,在哪里使用python语言和selenium 2库关键字更新机器人框架中的线程数和并行测试执行设置?此外,在哪里分配集线器url来触发执行?请建议可能的解决方案。注意:我们在脚本中使用selenium 2库关键字,而不是web驱动程序关键字,因此我无法使用“w

  • 我正在尝试使用Selenium执行自动化测试 org.openqa.selenium.WebDriverExc0019:错误转发新会话找不到:功能[{BrowserName=chrome, chromeOptions={args=[--start-最大化,--disable-web-Security],扩展=[], prefs={credentials_enable_service=false,p

  • null Appium--NodeConfig C:\mobile\AndroidConfig.json 我得到了一个例外: 信息:欢迎使用Appium V1.3.4(REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)信息:Appium REST http接口监听器在0.0.0.0:4723上启动信息:[debug]非默认服务器args:{“nodeConf