简体   繁体   中英

how to check if page QObject has been deleted in PhantomJS

I am trying to test code on a page that auto-closes after a form has been submitted.

 var page = require('webpage').create();
 page.evaluate(function() {
    //fill form and submit
 });

 if(page !== null) {
    page.evaluate(function() {
      //do something
    });
 }

Each time I try to check if(page !== null) I get an error stating

 Error: cannot access member `evaluate' of deleted QObject

instead of running my code when page is not null. What am I missing here? I just want to check if variable page or page's QObject has been deleted.

i'm using this code to check if page is "dead":

 if(page == undefined || page == null || (page+'')=='null'){
   console.log('page is dead')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM