Last active
March 5, 2018 12:18
-
-
Save sveneisenschmidt/144ad30b6bb8d348fe5d094727af43d1 to your computer and use it in GitHub Desktop.
Grab tracking id cookie
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
{ | |
'helpers': { | |
'Tracking': { | |
'require': './support/tracking_helper.js' | |
} | |
} | |
} |
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
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