Created
April 15, 2020 19:12
-
-
Save kerasai/20953ad146743ac27f69d2d9def60cd0 to your computer and use it in GitHub Desktop.
Set cookie on lighthouse - ugly hack
This file contains hidden or 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
// 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(); |
This file contains hidden or 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
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