Error while running the WebDriver tests as HtmlUnitDriver

1,063 views
Skip to first unread message

fmtjatt

unread,
May 1, 2013, 2:49:38 PM5/1/13
to webd...@googlegroups.com
I am trying to run WebDriver test in htmlunitdriver but they are failing:

I'm using Java/TestNg and Selenium 2.32.

Code:
HtmlUnitDriver driver = new HtmlUnitDriver();
driver.setJavascriptEnabled(true);

exception:

org.openqa.selenium.WebDriverException: java.net.MalformedURLException: unknown protocol: javascript Build info: version: &apos;2.19.0&apos;, revision: &apos;15849&apos;, time: &apos;2012-02-08 16:10:57&apos; System info: os.name: &apos;Windows 7&apos;, os.arch: &apos;amd64&apos;, os.version: &apos;6.1&apos;, java.version: &apos;1.7.0_17&apos; Driver info: driver.version: HtmlUnitDriver at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:331) at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitNavigation.to(HtmlUnitDriver.java:1048) at test.java.core.WebDriverSetup.setup(WebDriverSetup.java:81) Caused by: java.net.MalformedURLException: unknown protocol: javascript at java.net.URL.<init>(URL.java:592) at java.net.URL.<init>(URL.java:482) at java.net.URL.<init>(URL.java:431) at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:329) ... 28 more ... Removed 26 stack frames


Everything runs OK in the IE and Firefox driver. Do I need to download the htmlunit driver like the IEDriver? Any suggestions?

Thanks,
Gagan

fmtjatt

unread,
May 1, 2013, 3:05:24 PM5/1/13
to webd...@googlegroups.com
Got that resolved as it did not like fetching the url from the testng configuration file. Now it seems to be running but it is not printing anything on the console. Is this how it suppose to work?

fmtjatt

unread,
May 1, 2013, 3:25:46 PM5/1/13
to webd...@googlegroups.com
I tried running just a single singin/signout test and even that does not do anything. Eclipse shows like something is running there is not output and no ending. Anyone has any experience with HtmlUnitDriver?

Bill Ross

unread,
May 1, 2013, 7:28:16 PM5/1/13
to webd...@googlegroups.com
> Anyone has any experience with HtmlUnitDriver?

I have tried it twice at different jobs, and each time failed to get
login working. It seems brittle on javascript.

Bill

fmtjatt <gagan.d...@gmail.com> wrote:

> I tried running just a single singin/signout test and even that does not do
> anything. Eclipse shows like something is running there is not output and
> no ending. Anyone has any experience with HtmlUnitDriver?
>
> On Wednesday, May 1, 2013 12:05:24 PM UTC-7, fmtjatt wrote:
> >
> > Got that resolved as it did not like fetching the url from the testng
> > configuration file. Now it seems to be running but it is not printing
> > anything on the console. Is this how it suppose to work?
> >
> > On Wednesday, May 1, 2013 11:49:38 AM UTC-7, fmtjatt wrote:
> >>
> >> I am trying to run WebDriver test in htmlunitdriver but they are failing:
> >>
> >> I'm using Java/TestNg and Selenium 2.32.
> >>
> >> *Code:*
> >> HtmlUnitDriver driver = new HtmlUnitDriver();
> >> driver.setJavascriptEnabled(true);
> >>
> >> *exception:*
> >>
> >> org.openqa.selenium.WebDriverException: java.net.MalformedURLException:
> >> unknown protocol: javascript Build info: version: &apos;2.19.0&apos;,
> >> revision: &apos;15849&apos;, time: &apos;2012-02-08 16:10:57&apos; System
> >> info: os.name: &apos;Windows 7&apos;, os.arch: &apos;amd64&apos;,
> >> os.version: &apos;6.1&apos;, java.version: &apos;1.7.0_17&apos; Driver
> >> info: driver.version: HtmlUnitDriver at
> >> org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:331) at
> >> org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitNavigation.to(HtmlUnitDriver.java:1048)
> >> at test.java.core.WebDriverSetup.setup(WebDriverSetup.java:81) Caused by:
> >> java.net.MalformedURLException: unknown protocol: javascript at
> >> java.net.URL.<init>(URL.java:592) at java.net.URL.<init>(URL.java:482) at
> >> java.net.URL.<init>(URL.java:431) at
> >> org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:329)
> >> ... 28 more ... Removed 26 stack frames
> >>
> >>
> >> Everything runs OK in the IE and Firefox driver. Do I need to download
> >> the htmlunit driver like the IEDriver? Any suggestions?
> >>
> >> Thanks,
> >> Gagan
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.
> To post to this group, send email to webd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/webdriver?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Krishnan Mahadevan

unread,
May 1, 2013, 9:33:49 PM5/1/13
to webd...@googlegroups.com
I believe HtmlUnit is not known to work well with javascripts in particular. So unless the application under test is a fairly simple site I believe HtmlUnitDriver is not the best option. 
--
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/

Aniket Gadre

unread,
May 1, 2013, 10:08:41 PM5/1/13
to webd...@googlegroups.com

Try phantomjs

fmtjatt

unread,
May 3, 2013, 1:31:10 PM5/3/13
to webd...@googlegroups.com
Krishnan,

Are there any other tools available for WebDriver so we can do headless testing?

Thanks,


On Wednesday, May 1, 2013 6:33:49 PM UTC-7, Krishnan wrote:
I believe HtmlUnit is not known to work well with javascripts in particular. So unless the application under test is a fairly simple site I believe HtmlUnitDriver is not the best option. 

On Thursday, May 2, 2013, Bill Ross wrote:
> Anyone has any experience with HtmlUnitDriver?

I have tried it twice at different jobs, and each time failed to get
login working. It seems brittle on javascript.

Bill




--

Om

unread,
Jan 20, 2014, 6:11:35 AM1/20/14
to webd...@googlegroups.com
if any body knows answer for this type of error please reply me.
bcos i cant find the solution for this type error....


java.net.MalformedURLException: unknown protocol: javascript
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
Reply all
Reply to author
Forward
0 new messages