Reputation: 97
I'm using nodejs and nightwatchjs to run my test scripts.
I need to devise a test script that will check that a certain piece of information is displayed in the header of a webpage.
Below I have highlighted the information that I need to extract.
Once I've extracted this info, I will then test that a certain value is contained within this 'Headers' information (gpi=UID for example).
Are there any specific nodejs modules that could extract this information?
I've read request package info, but couldn't find a way of extracting the info.
Any help would be greatly appreciated.
Upvotes: 1
Views: 201
Reputation: 145
It looked like cookies is highlighted in your screenshot? If that is what you are after try this method off the browser object https://nightwatchjs.org/api/getCookie.html#apimethod-container
Upvotes: 0
Reputation: 22418
You can use the NightwatchJS API testing plugin so that you can then write a test to do expect
against the headers
it('demo test async', async function({supertest}) {
await supertest
.request(`https://myUrl.com`)
.get('<insert the path you want to test here e.g. / >')
.expect(200)
.expect('Content-Type', /json/);
});
The plugin page has a lot more details on it and you can always ask in their discord
Upvotes: 1