尝试使用Selenium网格

时间:2017-08-03 10:36:44

标签: selenium-chromedriver selenium-grid

尝试使用selenium网格启动自动化测试时收到以下错误。

启动此命令后,我正在运行集线器。

当我浏览http://10.1.27.27:4441/grid/register

我收到此错误消息:

HTTP ERROR 500
Problem accessing /grid/register. Reason:
Server Error
Caused by:
java.lang.IllegalStateException: Not a JSON Object: null
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:90)
at org.openqa.grid.web.servlet.RegistrationServlet.process(RegistrationServlet.java:84)
at org.openqa.grid.web.servlet.RegistrationServlet.doGet(RegistrationServlet.jav

启动中心的命令

C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4441
C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.jar -role wd -hub http://localhost:4441/grid/register

代码

var capabilities = DesiredCapabilities.Chrome();
capabilities.Platform = Platform.CurrentPlatform;
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4441/wd/hub"), capabilities);

收到错误讯息

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at Boden.Automation.Workflow.BodenMobileNavigation..ctor() in C:\Projects\UAT Automation\Dev\SourceCode\test.cs:line 43
at test..ctor() in C:\Projects\UAT Automation\Dev\SourceCode\test.cs:line 21

日志

Log

记录2

node log

更新

以下是我的行动。打开命令提示符(以管理员身份),导航到selenium jar文件夹并执行此命令

java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4441

此命令的输出位于:

C:\SeleniumGrid>java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4441
14:40:34.811 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
14:40:34.811 INFO - Launching Selenium Grid hub
2017-08-03 14:40:35.252:INFO::main: Logging initialized @603ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:40:35.262 INFO - Will listen on 4441
2017-08-03 14:40:35.299:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-08-03 14:40:35.322:INFO:osjs.session:main: DefaultSessionIdManager workerName=node0
2017-08-03 14:40:35.322:INFO:osjs.session:main: No SessionScavenger set, using defaults
2017-08-03 14:40:35.324:INFO:osjs.session:main: Scavenging every 600000ms
2017-08-03 14:40:35.329:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@154b04f{/,null,AVAILABLE}
2017-08-03 14:40:35.341:INFO:osjs.AbstractConnector:main: Started ServerConnector@13af739{HTTP/1.1,[http/1.1]}{0.0.0.0:4441}
2017-08-03 14:40:35.341:INFO:osjs.Server:main: Started @692ms
14:40:35.342 INFO - Nodes should register to 
http://10.1.27.27:4441/grid/register/
14:40:35.342 INFO - Selenium Grid hub is up and running

然后,我打开一个新的命令提示符(以管理员身份)并在selenium文件夹中执行以下命令

java -jar selenium-server-standalone-3.4.0.jar -role wd -hub http://localhost:4441/grid/register

此命令的输出位于:

C:\SeleniumGrid>java -jar selenium-server-standalone-3.4.0.jar -role wd -hub http://localhost:4441/grid/register
14:41:19.175 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
14:41:19.175 INFO - Launching a Selenium Grid node
2017-08-03 14:41:19.516:INFO::main: Logging initialized @505ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:41:19.563 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:41:19.563 INFO - Driver provider com.opera.core.systems.OperaDriver 
registration is skipped:Unable to create new instances on this machine.
14:41:19.564 INFO - Driver class not found: com.opera.core.systems.OperaDriver
14:41:19.564 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
14:41:19.565 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
2017-08-03 14:41:19.592:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-08-03 14:41:19.613:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@10f1111{/,null,AVAILABLE}
2017-08-03 14:41:19.625:INFO:osjs.AbstractConnector:main: Started ServerConnector@23e5ee{HTTP/1.1,[http/1.1]}{0.0.0.0:5555}
2017-08-03 14:41:19.626:INFO:osjs.Server:main: Started @615ms
14:41:19.626 INFO - Selenium Grid node is up and ready to register to the hub
14:41:19.636 INFO - Starting auto registration thread. Will try to register every 5000 ms.
14:41:19.636 INFO - Registering the node to the hub:http://localhost:4441/grid/register
14:41:19.675 INFO - The node is registered to the hub and ready to use

C#错误(在visual studio中运行)

在OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)    在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2参数)    在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)    在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities)    在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress,ICapabilities desiredCapabilities)    at .... ctor()在C:\ Projects \ UAT Automation \ Dev \ SourceCode ... cs:第38行    at .... ctor()in C:\ Projects \ UAT Automation \ Dev \ SourceCode ... cs:line 21

这是我收到的错误

visual studio and command prompts screen shot

0 个答案:

没有答案