PhantomJS 1.9.7 - page not loading fully when javascript used to populate content

239 views
Skip to first unread message

Adam Williams

unread,
Jul 23, 2014, 6:40:54 AM7/23/14
to phan...@googlegroups.com
I'm using PhantomJS via Selenium (PhantomJSDriver / GhostDriver).  For the most part, it works perfectly.  But I'm having some difficulties with some pages and it seems to be ones that rely heavily on javascript to load their content.

Basically the pages never load fully.  The main template of the page will load but none of the content ever appears.  I've tried setting implicit and explicit waits with long timeouts (e.g. 30 seconds).  I've also tried setting a long script timeout when configuring my PhantomJSDriver with no luck.  So it appears the scripts are never executing.

It works ok with other implementations of WebDriver (ChromeDriver, etc).

I've found a good example of a public website that demonstrates the problem:  http://www.stanjames.com/UK/541/Homepage

I'm simply using


to load the page, but if I export a screenshot after page load, all I get is the attached "stanjames.png".

I also exported the page source and have attached as "source.txt".  A couple of things jump out at me:

1.  Most of the javascript that loads the page content is held externally, on a different domain
2.  Those scripts require a secure connection (https)
3.  One of the scripts is located even before the <head> tag, which seems unusual

Could any of those things cause problems for PhantomJS and if so, does anyone have an idea of how to work around the problem?

In case it's useful, here's how I'm currently configuring my PhantomJSDriver:

    private WebDriver configureWebClient(){
       
WebDriver client = null;        
       
DesiredCapabilities caps = new DesiredCapabilities();

        caps
.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--webdriver-loglevel=WARNING", "--web-security=no", "--ignore-ssl-errors=yes"});
        caps
.setCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36");
        caps
.setCapability("phantomjs.page.customHeaders.Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
        caps
.setCapability("phantomjs.page.customHeaders.Accept-Language", "en-GB,en-US;q=0.8,en;q=0.6");

        client
= new PhantomJSDriver(caps);        
        client
.manage().window().setSize(new Dimension(1366,768));

       
return client;
   
}


stanjames.png
source.txt

Anju Yadav

unread,
Aug 3, 2017, 9:49:38 AM8/3/17
to phantomjs, dod...@gmail.com
Hi Adam, 

Did you find solution to this problem?

I am also stuck with same problem 

Regards,
Anju
Reply all
Reply to author
Forward
0 new messages