some lazyload data can't be filled by javascript.
below is my code:
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setJavaScriptTimeout(99999);
webClient.waitForBackgroundJavaScript(99999);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
try {
HtmlPage productPage = (HtmlPage)webClient.getPage("http://detail.1688.com/offer/1228752603.html");
HtmlElement dealElement = (HtmlElement) productPage.getFirstByXPath("//*[@id=\"mod-detail-otabs\"]/ul/li[2]/a/span");
HtmlElement commentElement = (HtmlElement) productPage.getFirstByXPath("//*[@id=\"commentbody\"]/dl[1]/dd/div[2]");
if(dealElement!=null)
{
System.out.println(dealElement.asXml());
}
if(commentElement!=null)
{
System.out.println(commentElement.asXml());
}
System.out.println(productPage.asText());
}
the dealElement and commentElement return null;
Compare the result of HtmlUnit to Chrome, the dealElement is not null,
and the data is filled by scrolling down.
If it's a problem of my code,Please tell me.THS~
wait..
wait wait wait...
Hi Adam,
You need to provide minimal test case, that shows the needed scrolling behavior.
The team is very small to investigate all cases.
Please read http://htmlunit.sourceforge.net/submittingJSBugs.html
i've solved the problem,Ahmed Ashour,thanks~
Great it is resolved.
Hi Adam,
Can you please post your solution here.
I am facing similar issue. I am trying to load a page and some elements are not being loaded (lazy loading issue). We can benefit from your solution.
Thank you,
Tarandeep