Not able to instantiate RemoteWebDriver in Java

436 views
Skip to first unread message

Vijay V

unread,
Apr 9, 2012, 2:52:15 AM4/9/12
to Selenium Users
Hello,

I am using below piece of code to instantiate RemoteWebDriver. But I
am getting an exception.

Please look into the code and exception below and help me out to sort
this issue.

Code:
********************************************************************************************
public void startSeleniumServer() throws MalformedURLException{
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("http://localhost:4444/wd/hub");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
capabilities.setPlatform(Platform.ANY);
capabilities.setBrowserName("Firefox");
driver = new RemoteWebDriver(capabilities); // (Exception seen at
this line)
selenium = new WebDriverBackedSelenium(driver, "http://
www.google.com");
}
********************************************************************************************

Exception Seen
**********************************************************************************************
Exception in thread "main" org.openqa.selenium.WebDriverException:
java.net.MalformedURLException
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27
19:03:59'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at
org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:
101)
at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:
102)
at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:
98)
at
com.AddUserWebDriverNative.startSeleniumServer(AddUserWebDriverNative.java:
404)
at com.AddUserWebDriverNative.main(AddUserWebDriverNative.java:357)
Caused by: java.net.MalformedURLException
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at
org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:
98)
... 4 more
**********************************************************************************************

Please shed some light on this one. Any help would be highly
appreciated.

Thanks in advance....!

Regards,
Vijay

Mike Riley

unread,
Apr 9, 2012, 1:12:42 PM4/9/12
to seleniu...@googlegroups.com
You may need to tell it where the remote server is located (I use a Grid2 Hub in this example):

        driver = new RemoteWebDriver(new URL("http://" + host + ":" + port +
                                             "/wd/hub"), capability);

I am not sure off the top of my head just what it defaults to otherwise, but my guess would be the current systems IP address and port 4444.  So unless your remote server is on your local system you need to tell it where to find it.

Mike

Vijay V

unread,
Apr 10, 2012, 2:27:04 AM4/10/12
to Selenium Users
Hi Mike,

Thanks for your prompt reply.

I have tried both, my system IP address as well as remote server IP
address. But still seeing same error.

Please note: I am not using Selenium Grid, but just using WebDriver.

If you have some piece of working code which start selenium server
using RemoteWebDriver please post it here. Let me give it a try.

Regards,
Vijay

Krishnan Mahadevan

unread,
Apr 10, 2012, 4:04:55 AM4/10/12
to seleniu...@googlegroups.com
If you are working with WebDriver and not intending to use the Grid, then why would you be using RemoteWebDriver to start with ?
Can you please elaborate more on what exactly are you trying to do here ?

Thanks & Regards
Krishnan Mahadevan

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



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Reply all
Reply to author
Forward
0 new messages