I have been writing some test cases in PhantomJs and CasperJs. Recently I stumbled on NightmareJs which uses ElectronJs.
I wanted to know if I can automate POST requests (such as below) in NigthmareJs (maybe using goto, but I don't see any specifications for passing in params and changing the method):
PhantomJs code:
page.open(url, 'post', params, function (status) {/*something*/});
And if so can I loop it a couple of times to monitor the time taken.
I think you are looking for node-rest-client
var Client = require('node-rest-client').Client;
var client = new Client();
var args = {
data: reqBody,
headers: {
"Content-Type": "application/json; charset=UTF-8"
}
};
//console.log(args);
var req = client.post("mypage/postResult", args, function(data, response) {
console.log('Sent data: ', JSON.stringify(data, null, 2));
});
req.on('error', function(err) {
console.log("Ouput posting failed due to error.", err);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With