简体   繁体   English

Internet Explorer未启动我的selenium webdriver代码

[英]Internet Explorer is not launching my selenium webdriver code

Selenium WebDriver code is: Selenium WebDriver代码是:

File file = new File("D:\\Polycom_Space\\WebdriversIEDriverServer_x64_2.53.1\\IEDriverServer.exe");

System.setProperty("webdriver.ie.driver",file.getAbsolutePath());
capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE");
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability("requireWindowFocus", true);
driver = new RemoteWebDriver(host, capabilities);



**//grid node configuration is---**

cd Polycom_Space\Java Libraries Server
java -jar selenium-server-standalone-2.53.1.jar -role webDriver -hub http://localhost:4242/grid/register -port 5557 -Dwebdriver.ie.driver=D:\Polycom_Space\Webdrivers

\IEDriverServer_x64_2.53.1\IEDriverServer.exe -browser browserName="internet explorer" -maxInstances=4 -maxSession 1

Exception is: 例外情况是:

org.testng.internal.thread.ThreadExecutionException: org.testng.internal.InvokeMethodRunnable$TestNGRuntimeException: java.lang.RuntimeException: Error forwarding the new session cannot find : Capabilities [{ensureCleanSession=true, acceptSslCerts=true, requireWindowFocus=true, browserName=IE, version=, platform=WINDOWS}] org.testng.internal.thread.ThreadExecutionException:org.testng.internal.InvokeMethodRunnable $ TestNGRuntimeException:java.lang.RuntimeException:转发新会话时出错无法找到:Capabilities [{ensureCleanSession = true,acceptSslCerts = true,requireWindowFocus = true,browserName = IE,版本=,平台= WINDOWS}]

The -D properties should come before the jarfile (otherwise it is treated as an argument of the application, not an option of the JVM). -D属性应该在jarfile之前(否则它被视为应用程序的参数,而不是JVM的选项)。 From java help, the usage is 从java帮助,用法是

java [-options] -jar jarfile [args...]

Try executing it with 尝试执行它

java -Dwebdriver.ie.driver=D:\Polycom_Space\Webdrivers\IEDriverServer_x64_2.53.1\IEDriverServer.exe -jar selenium-server-standalone-2.53.1.jar -role webDriver -hub http://localhost:4242/grid/register -port 5557 -browser browserName="internet explorer" -maxInstances=4 -maxSession 1

The problem lies in your test code. 问题在于您的测试代码。

Error forwarding the new session cannot find 转发新会话时出错无法找到

is the grid's way of telling you that whatever node you requested for (based on your capability), the grid could not find in its farm of nodes. 是网格的方式告诉您,无论您请求的节点(基于您的能力),网格都无法在其节点场中找到。

Your test code is requesting for a browser whose name is IE , but the Grid has only one node which supports a browser named internet explorer 您的测试代码正在请求名称为IE的浏览 ,但Grid只有一个支持名为Internet Explorer的浏览器的节点

The line 这条线

capabilities=DesiredCapabilities.internetExplorer(); 能力= DesiredCapabilities.internetExplorer();

already takes care of setting the browser name properly. 已经负责正确设置浏览器名称。

So you don't need the below line (this is the line that is causing the issue) : 所以你不需要以下行(这是引起问题的行):

capabilities.setCapability(CapabilityType.BROWSER_NAME, "IE"); capabilities.setCapability(CapabilityType.BROWSER_NAME,“IE”);

Please remove that line and try again. 请删除该行,然后重试。

Also its better to tweak your node capabilities via a nodeConfig JSON file rather than you trying to pass them via the command line (its easy to make mistakes when using the command line) 最好通过nodeConfig JSON文件调整节点功能,而不是尝试通过命令行传递它们(使用命令行时容易出错)

This document should help you get oriented with JSON node configs. 文档应该可以帮助您使用JSON节点配置进行定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM