I am using Nightwatch and was hoping to monitor the http requests that are being generated by my nightwatch steps. Is there a way to listen to the requests that are sent and the responses received. I dont need to modify them.
Thanks Matt
I am using Nightwatch and was hoping to monitor the http requests that are being generated by my nightwatch steps. Is there a way to listen to the requests that are sent and the responses received. I dont need to modify them.
Thanks Matt
Yes there is a way.
In order to monitor the HTTP requests: It's basically will monitor when user click on event that send a request to the server such as: submit button in login page - that send userName & password.
First install npm i nightwatch-xhr
after that you can make a function like that:
module.exports = {
tags: ["test"],
"test": function (browser) {
browser
.windowMaximize()
.url("some url")
.insertValue("namevalue")
.insertValue("passwordValue")
//then write something like that
.waitForXHR(
"",
1000,
function browserTrigger() {
browser.click("submit button")
},
function assertValues(xhr) {
console.log(xhr)
}
);
}
}
It will catch the request data that send to the server.
© 2022 - 2024 — McMap. All rights reserved.