HtmlUnitDriver vs FireFoxDriver

Sett 617 ganger
Hopp til første uleste melding

Erron

ulest,
21. aug. 2009, 12:02:1621.08.2009
til webdriver
I have a very simple test I'm creating to run a smoke test of about
300 sites.

So, my code looks like:
private final WebDriver driver;

public TestHomePage(String siteUrl) {
driver = new FirefoxDriver();
driver.get(siteUrl);
}

public void checkHomePage() {
System.out.println("Page title is: " + driver.getTitle());
boolean isErrorPage = driver.getTitle().contains("Error");
System.out.println("Page url is: " + driver.getCurrentUrl());
isErrorPage = isErrorPage ? true : driver.getPageSource
().contains("Coming Soon!!");
isErrorPage = isErrorPage ? true : driver.getPageSource
().contains("Error Message");
isErrorPage = isErrorPage ? true : driver.getPageSource
().contains("Technical Difficulties");
List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Number of Links: " + links.size());
}

The problem I'm having is the test runs fine for FireFoxDriver. But as
soon as I run with the test with new HtmlUnitDriver(), I get an error:

Exception in thread "main" org.openqa.selenium.WebDriverException:
java.lang.NullPointerException
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_12'
Driver info: driver.version: htmlunit
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get
(HtmlUnitDriver.java:228)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get
(HtmlUnitDriver.java:211)
at com.diginsite.product.webcenter.TestBackPage.<init>
(TestBackPage.java:17)
at com.diginsite.product.webcenter.TestHomePage.checkLinks
(TestHomePage.java:49)
at com.diginsite.product.webcenter.TestHomePage.checkHomePage
(TestHomePage.java:40)
at com.diginsite.product.webcenter.TestingHarness.main
(TestingHarness.java:16)
Caused by: java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:80)
at org.cyberneko.html.HTMLScanner$ContentScanner.changeEncoding
(HTMLScanner.java:2679)
at org.cyberneko.html.HTMLScanner$ContentScanner.scanPI
(HTMLScanner.java:2537)
at org.cyberneko.html.HTMLScanner$ContentScanner.scan
(HTMLScanner.java:1990)
at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:910)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:
499)
at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:
452)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser
$HtmlUnitDOMBuilder.parse(HTMLParser.java:771)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse
(HTMLParser.java:252)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage
(DefaultPageCreator.java:127)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage
(DefaultPageCreator.java:101)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto
(WebClient.java:439)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:
327)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:
384)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.get
(HtmlUnitDriver.java:222)
... 5 more


My guess is that this is caused my malformed HTML. However, I have
not seen any documentation stating that the HTML must be well-formed.

Any ideas of what this issue could be?

Thanks,

Erron

Erron

ulest,
21. aug. 2009, 15:24:5021.08.2009
til webdriver
Update: I changed the url to www.google.com and the code worked
fine. So, I'm confident that it must be malformed html causing the
issue.

Thanks,

Erron

Ahmed Ashour

ulest,
22. aug. 2009, 05:01:0822.08.2009
til webd...@googlegroups.com
Hi Erron,
 
What is the site that gives that error? And can you provide a minimal HTML?
 
Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Erron <erron....@gmail.com>
To: webdriver <webd...@googlegroups.com>
Sent: Friday, August 21, 2009 10:24:50 PM
Subject: [webdriver] Re: HtmlUnitDriver vs FireFoxDriver
>         at com.diginsite.product.webcenter..TestHomePage.checkLinks

Marc Guillemot

ulest,
24. aug. 2009, 04:08:3924.08.2009
til webd...@googlegroups.com
Hi,

I think that this is an issue in NekoHTML that has been fixed since last
release. I'm not sure if you can simply use a NekoHTML snapshot in place
of current release. Otherwise next HtmlUnit release should come soon ;-)

BTW: you should probably cache the result of driver.getPageSource() to
improve performance a bit.

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com
Svar alle
Svar til forfatter
Videresend
0 nye meldinger