Internet Explorer 没有启动我的 selenium webdriver 代码

Internet Explorer is not launching my selenium webdriver code

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

例外情况是:

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}]

-D 属性应该在 jar 文件之前(否则它被视为应用程序的参数,而不是 JVM 的选项)。 来自java帮助,用法是

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

尝试用

执行它
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

问题出在你的测试代码上。

Error forwarding the new session cannot find

是网格告诉您无论您请求什么节点(根据您的能力),网格无法在其节点场中找到的方式。

您的测试代码正在请求名为 IE 的浏览器,但网格只有一个节点支持名为 internet explorer[=34] 的浏览器=]

capabilities=DesiredCapabilities.internetExplorer();

已正确设置浏览器名称。

因此您不需要以下行(这是导致问题的行):

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

请删除该行并重试。

此外,最好通过 nodeConfig JSON 文件调整节点功能,而不是尝试通过命令行传递它们(使用命令行时很容易出错)

This 文档应该可以帮助您了解 JSON 节点配置。