Getting exception: Exception in thread "main" org.openqa.selenium.UnsupportedCommandException

630 views
Skip to first unread message

anemuday

unread,
Apr 8, 2016, 8:13:13 AM4/8/16
to Selenium Users
OS: Windows 7 32 bit
Selenium Version: selenium-server-standalone-2.47.1.jar
Browser: Chrome / Firefox
Browser Version: 49

in command prompt started hub by specifying:
java -jar selenium-server-standalone-2.47.1.jar -role hub


D:\UD\jars>java -jar selenium-server-standalone-2.47.1.jar -role hub
16:25:25.386 INFO - Launching Selenium Grid hub
2016-04-08 16:25:27.804:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2016-04-08 16:25:27.955:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContext
Handler{/,null}
2016-04-08 16:25:28.014:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.
0.0:4444
16:25:28.016 INFO - Nodes should register to http://192.168.2.2:4444/grid/regist
er/
16:25:28.018 INFO - Selenium Grid hub is up and running
**16:31:12.162 INFO - Registered a node http://192.168.2.2:5557** this one is after registering node

Following is node launch in the same machine:

D:\UD\jars>java -jar selenium-server-standalone-2.47.1.jar -role webdriver -hub
http://192.168.2.2:4444/grid/register/ -port 5557
16:31:09.417 INFO - Launching a Selenium Grid node
16:31:11.693 INFO - Java: Oracle Corporation 25.45-b02
16:31:11.694 INFO - OS: Windows 7 6.1 x86
16:31:11.707 INFO - v2.47.1, with Core v2.47.1. Built from revision 411b314
16:31:11.841 INFO - Driver class not found: com.opera.core.systems.OperaDriver
16:31:11.842 INFO - Driver provider com.opera.core.systems.OperaDriver is not re
gistered
16:31:12.011 INFO - Selenium Grid node is up and ready to register to the hub
16:31:12.112 INFO - Starting auto registration thread. Will try to register ever
y 5000 ms.
16:31:12.112 INFO - Registering the node to the hub: http://192.168.2.2:4444/gri
d/register
16:31:12.163 INFO - The node is registered to the hub and ready to use

After that executed below code:

import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class gridEx 
{
    static RemoteWebDriver driver;
    public static void main(String[] args) throws MalformedURLException 
    {
        DesiredCapabilities caps=new DesiredCapabilities().chrome();
        caps.setPlatform(Platform.VISTA);
        caps.setBrowserName("chrome");

        driver=new RemoteWebDriver(new URL("http://192.168.2.2:5557"),caps);

        driver.get("http://www.google.com");
        driver.findElementByName("q").sendKeys("Hello world");
        driver.quit();
    }
}

Getting below exception:

Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: <html>
<head>
<title>Error 403 Forbidden for Proxy</title>
</head>
<body>
<h2>HTTP ERROR: 403</h2><pre>Forbidden for Proxy</pre>
<p>RequestURI=/session</p>
<p><i><small><a href="http://jetty.mortbay.org">Powered by Jetty://</a></small></i></p>

</body>
</html>
Command duration or timeout: 390 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'user-PC', ip: '192.168.2.2', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
    at gridEx.main(gridEx.java:18)

⇜Krishnan Mahadevan⇝

unread,
Apr 8, 2016, 9:35:21 AM4/8/16
to Selenium Users
Change driver=new RemoteWebDriver(new URL("http://192.168.2.2:5557"),caps);
​to ​driver=new RemoteWebDriver(new URL("http://192.168.2.2:5557/wd/hub"),caps);

​and try again.​


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b285c13c-ae05-4a8f-b5ff-4455227473a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anemuday

unread,
Apr 10, 2016, 7:24:03 AM4/10/16
to Selenium Users
Hi,

Its by mistake i forgot to add "/wd/hub".

But when i am trying to access the ChromeDriver through Chrome, i am getting below exception:
Exception in thread "main" org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Command duration or timeout: 410 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'user-PC', ip: '192.168.2.6', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at gridEx.main(gridEx.java:19)
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:290)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

But when i used the same path of chromedriver below which is normal ChromeDriver invocation, which works perfect.
System.setProperty("webdriver.chrome.driver", "D:\\UD\\jars\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.google.com");
System.out.println(driver.getTitle());
driver.quit();
Whey i am getting above exception when i ChromeDriver in Grid context??
System.setProperty("webdriver.chrome.driver", "D:\\UD\\jars\\chromedriver.exe");
DesiredCapabilities caps=new DesiredCapabilities().chrome();
caps.setPlatform(Platform.VISTA);
caps.setBrowserName("chrome");
driver=new RemoteWebDriver(new URL("http://192.168.2.6:5555/wd/hub"),caps);
driver.get("http://www.google.com");
driver.findElementByName("q").sendKeys("Hello world");
driver.quit();

Krishnan mahadevan

unread,
Apr 10, 2016, 7:41:54 AM4/10/16
to seleniu...@googlegroups.com
Start your node by adding -Dwebdriver.chrome.driver and pass the location of the chrome driver binary to the above mentioned JVM arg and retry your test. 

You cannot use System.setProperty to set a property for the node. The node has to be either spun off by passing that property via JVM args or you can ensure that chromedriver binary is available as part of the PATH variable.


-Krishnan Mahadevan


"All the desirable things in life are either illegal, expensive, fattening or in love with someone else"

From: anemuday
Sent: ‎10-‎04-‎2016 16:54
To: Selenium Users
Subject: Re: [selenium-users] Getting exception: Exception in thread "main"org.openqa.selenium.UnsupportedCommandException

[The entire original message is not included.]

anemuday

unread,
Apr 10, 2016, 1:59:51 PM4/10/16
to Selenium Users
Thanks Krishnan,

Your inputs helped me. After providing the "-Dwebdriver.chrome.driver=chromedriver physical file path",
it started working.

Thanks,
Uday
Reply all
Reply to author
Forward
0 new messages