CasperJS browser alerts

26 views
Skip to first unread message

Charitha Gunerathne

unread,
Feb 27, 2017, 11:43:52 AM2/27/17
to CasperJS
How to handle capserJS browser alerts?

philippe....@oscaro.com

unread,
Mar 6, 2017, 6:10:31 AM3/6/17
to CasperJS
Hello  Charitha Gunerathne,

You can use waitForAlert()

Advanced example:
// waiting for alert
casper
.waitForAlert(
   
function success(response) {            
        casper
.test.pass('alert received');
       
        test
.assertEquals(response.data, alert_message, 'alert has the correct content');
        casper
.test.pass('alert validated');
   
},
   
function fail() {
       
this.die('alert NOT received');
});


Reply all
Reply to author
Forward
0 new messages