简体   繁体   中英

Internet Explorer is not launching my selenium webdriver code

Selenium WebDriver code is:

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

The -D properties should come before the jarfile (otherwise it is treated as an argument of the application, not an option of the JVM). From java help, the usage is

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

The line

capabilities=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");

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)

This document should help you get oriented with JSON node configs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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