Skip to content

get to know when the ajax calls are made and done #2

@singamcet

Description

@singamcet

how to know when ajax calls are made and done .....then how to check the page is fully loaded or not
am new to nightmare js
my code is here

var Nightmare = require('nightmare');
require('nightmare-webrequest-addon');

var name = "vineeth";
var cancel = false;

var nightmare = Nightmare({
show: true,
switches: {
'proxy-server': 'localhost:3128' , // set the proxy server here ...
'ignore-certificate-errors' : true
},

});

nightmare.on('onBeforeRequest', function(details, callback){
if(details && details.hasOwnProperty("resourceType")){
console.log(details.resourceType)
}
//callback(details);
})

nightmare.onBeforeRequest([ "*.css" ],function(details, callback){
if(details && details.hasOwnProperty("resourceType") && details.resourceType == "image"){
callback({ cancel : true } )
}
else{
callback({ cancel : false } )
}
})

nightmare
.goto('https://www.flipkart.com/zesture-cotton-floral-double-bedsheet/p/itmepqvqyyzznfsn?pid=BDSEPQVQCGMQRY7Y&srno=b_1_2&otracker=hp_reco_Discounts%20for%20You_2_Min%2050%25%20off_vdm%2Fuj4%2F64i_1&lid=LSTBDSEPQVQCGMQRY7YJBFIYW&fm=personalisedRecommendation/discount&iid=513dcd7a-61cb-4633-845f-bff06e73fddd.BDSEPQVQCGMQRY7Y.SEARCH')
// .wait(10000)
.end()
.then(function(ip) { // This will log the Proxy's IP
console.log('proxy IP:', ip);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions