Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for URL change in Casper.js?

There is a waitForUrl() functionality in Casper.js, but is it possible to waitForUrlChange() in Casper.js?

I mean detecting a change in this.getCurrentUrl() value. I can't predict the new url value. It can be anything.

like image 653
Jérôme Verstrynge Avatar asked Jan 21 '15 18:01

Jérôme Verstrynge


1 Answers

There's an event handler for it

casper.on('url.changed',function(url) {
casper.echo(url);
});

Here's the documentation for it: http://casperjs.readthedocs.org/en/latest/events-filters.html#url-changed

However, as Artjom B. mentioned, this won't cover all cases that a function extension would handle. It's only really appropriate when you don't need it as part of the control flow, but just want to reactively scrape some values when it happens.

like image 126
Mic Avatar answered Oct 16 '22 22:10

Mic