Reputation: 559
I am using casperjs as a testing tool for my application. I am facing a weird issue here.
casper.then(function () {
this.click('a[href="/ui/thunder/"]')
})
casper.then(function () {
this.test.assertUrlMatch(/ui\/thunder\/$/, 'Redirected to cloud page');
console.log(this.getHTML());
});
on writing this piece of code, i get redirected to the ui/thunder page, and on the console log this.getHTML(), it shows me the full html of the page, but some of the information is still missing.
While the pages loads, it does several REST api calls, and the data is loaded on the screen, but casperjs doesnt show that data coming from the server.
Eg: when the page loads, it calls the REST service /auth/users, which I display in the <div class="user"></div>
tag.
So in the browser when i see, it is filled like this
<div class = "user">
<div class "userName">User1</div>
<div class "userName">User2</div>
</div>
but when i do a console.log in casperjs for this.getHTML(), i get the <div class="user"></div>
(empty tag without any user)
Any idea why is this happening?
Upvotes: 3
Views: 862
Reputation: 559
The Casperjs's webkit was failing to render my page since there was a small javascript binding error which was never caught by firefox/chrome/IE. I downloaded Konqueror and found that it also doesn't render the page, and on fixing that binding issue, my life got much easier with casperjs!
Upvotes: 0
Reputation: 11414
You may want to wait for the url to be actually loaded in the browser:
casper.then(function () {
this.click('a[href="/ui/thunder/"]')
});
casper.waitFor(function() {
return /ui\/thunder\/$/.test(this.getCurrentUrl());
}, function () {
console.log(this.getHTML());
});
Upvotes: 1