Menu ▾ ▴

#1693 Lazyload data can'g be filled by javascript.

Latest SVN
closed
nobody
None
1
2015-12-28
2015-06-10
adam
No

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~

Discussion

  • adam

    adam - 2015-06-15

    wait..

     
  • adam

    adam - 2015-06-25

    wait wait wait...

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-06-25

    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

     
  • adam

    adam - 2015-07-23

    i've solved the problem,Ahmed Ashour,thanks~

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-07-23

    Great it is resolved.

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-07-23
    • status: open --> closed
     
  • Tarandeep Singh

    Tarandeep Singh - 2015-12-28

    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

     

Log in to post a comment.