Skip to content

Instantly share code, notes, and snippets.

@sveneisenschmidt
Last active March 5, 2018 12:18
Show Gist options
  • Save sveneisenschmidt/144ad30b6bb8d348fe5d094727af43d1 to your computer and use it in GitHub Desktop.
Save sveneisenschmidt/144ad30b6bb8d348fe5d094727af43d1 to your computer and use it in GitHub Desktop.
Grab tracking id cookie
{
'helpers': {
'Tracking': {
'require': './support/tracking_helper.js'
}
}
}
const helpers = ['WebDriverIO', 'Protractor', 'Puppeteer', 'Nightmare'];
let helper;
class Tracking extends codecept_helper {
_before() {
// Tries to identify avaialble helpers, if a supported helper is found,
// variable `helper` is set and the lookup is stopped
helpers.forEach((lookupHelper) => {
if (!helper && this.helpers[lookupHelper]) {
helper = this.helpers[lookupHelper];
}
});
}
// Grabs the tracking id from cookies and decodes it if present
async grabTrackingId() {
const cookie = await helper.grabCookie('trackingId');
return !!cookie ? decodeURIComponent(cookie.value) : false;
}
}
module.exports = Tracking;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment