phantomjs - Make CasperJS fully reload fragment (hashbang) links -


when use example here find range of hashbang links on same page (that dynamically creates different content) generates content first time. other results, this.gethtml() first link used.

e.g. when load http://test.localhost/ , finds:

http://test.localhost/#!/page1 http://test.localhost/#!/page2 http://test.localhost/#!/page3 

every iteration uses content of #!/page1. when add list in reverse order, every iteration uses content of #!/page3. it's works first time, casperjs or phantomjs internally detects hash change in stead of new url, doesn't load onhashchange functionality, , ignores it.

how make casperjs load every url anew, if hash changes, if opened first time?

i'm using phantomjs 1.9.18 comes automatically grunt job.

this may bug in phantomjs 1.x (no guarantees). if don't want update phantomjs version 2, might want each iteration "a clean slate" judging observations. seems you're opening pages sequentially this:

casper.thenopen(url[0], function(){ /* something*/ }); casper.thenopen(url[1], function(){ /* something*/ }); casper.thenopen(url[2], function(){ /* something*/ }); 

one way workaround issue might load different page in between invocations:

casper.thenopen(url[0], function(){ /* something*/ }); casper.thenopen("http://example.com"); casper.thenopen(url[1], function(){ /* something*/ }); casper.thenopen("http://example.com"); casper.thenopen(url[2], function(){ /* something*/ }); 

http://example.com perfect cases this, because it's online , small, still produces unnecessary requests. way reset current page "about:blank" after you're done it:

casper.thenopen(url[0], function(){ /* something*/ }); casper.then(function(){ this.page.content = ""; }); casper.thenopen(url[1], function(){ /* something*/ }); casper.then(function(){ this.page.content = ""; }); casper.thenopen(url[2], function(){ /* something*/ }); 

page.content = '' empties content of page , changes current url, next open operation can clean.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -