Skip to content

Instantly share code, notes, and snippets.

@kerasai
Created April 15, 2020 19:12
Show Gist options
  • Save kerasai/20953ad146743ac27f69d2d9def60cd0 to your computer and use it in GitHub Desktop.
Save kerasai/20953ad146743ac27f69d2d9def60cd0 to your computer and use it in GitHub Desktop.
Set cookie on lighthouse - ugly hack
// Set request blocking before any network activity
// No "clearing" is done at the end of the pass since blockUrlPatterns([]) will unset all if
// neccessary at the beginning of the next pass.
await passContext.driver.blockUrlPatterns(blockedUrls);
await passContext.driver.setExtraHTTPHeaders(passContext.settings.extraHeaders);
// Add this call for setting the cookie.
await passContext.driver.setCookie();
class Driver {
/**
* Needs this method added to the Driver class.
*/
async setCookie() {
let val = {
name: 'cookie_name',
value: 'cookie_value',
domain: 'example.local',
path: '/'
};
return this.sendCommand('Network.setCookie', value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment