forked from nightwatchjs/nightwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Getting HTTP headers of the url page response directly in a Nightwatch test nightwatchjs#4250 github- Harshit-7373
- Loading branch information
1 parent
8f4a330
commit 69534e8
Showing
2 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
'Test if headers are captured correctly': function (browser) { | ||
browser.url('https://example.com', {captureHeaders: true}, function (result) { | ||
const headers = browser.getHeaders(); | ||
|
||
// Ensure headers object is available | ||
if (!headers) { | ||
console.error('Headers could not be retrieved!'); | ||
browser.assert.fail('Headers object is undefined or null'); | ||
|
||
return; | ||
} | ||
|
||
// Log headers for debugging purposes | ||
console.log('Captured Headers:', headers); // eslint-disable-line no-console | ||
|
||
// Assertions to validate specific headers | ||
browser.assert.ok(headers['content-type'], 'Content-Type header is present'); | ||
browser.assert.equal( | ||
headers['content-type'], | ||
'text/html; charset=UTF-8', | ||
'Content-Type header matches expected value' | ||
); | ||
}); | ||
|
||
browser.end(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters