Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CasperJS back navigation doesn't work?

Here's the situation:

  1. I use CasperJS to open a page
  2. I click on button on the page to go to page2
  3. I click a button on page2 to go to page3

Now I am on page 3 and I call this.back() within a then statement and it does go back to page 2 and everything just stops executing after that

I also tried to call

this.then(function() {
    this.evaluate(function() {
        history.go(-1);
    });
});

and it goes back to page2 and gets stuck again. The next line won't execute.

Any ideas or is this a bug?

like image 668
user3255100 Avatar asked Feb 22 '26 09:02

user3255100


1 Answers

Typically, the following code works for me:

casper.then(function () {
    this.back();
});

Make sure you are running on a step your code and finally, in a separate step, the step of returning the page. This is necessary so that your .back be done AFTER your code.

like image 197
Diego Borges Avatar answered Feb 24 '26 23:02

Diego Borges