Set request header

Updates request header value for all future requests.
client.setRequestHeader(headerName, headerValue);

This function allows updating the header values for any requests that browser sends out. The parameter headerName is the name of the request header to be changed. The parameter headerValue is used to set a new value for the specified header.

To reset request header to its default value, passnullas the new header value.

Setting headerValueto an empty string will actually update the request header value to an empty string.

function(client) {
// Example of setting custom request header value
client
// Open page and create screenshot with default request header
.url('http://www.xhaus.com/headers')
.waitForElementVisible('body', 2000)
.takeScreenshot('default.png')
// Set custom request header, reload the page and create screenshot
.setRequestHeader('Keep-Alive','timeout=5, max=1000')
.refresh()
.waitForElementVisible('body', 2000)
.takeScreenshot('custom.png')
// Reset request header, reload the page and create screenshot
.setRequestHeader('Keep-Alive', null)
.refresh()
.waitForElementVisible('body', 2000)
.takeScreenshot('reset.png')
}