@telus/telus-nightwatch-commands
v2.12.1
Published
Nightwatch custom commands for Telus Digital
Downloads
91
Readme
Telus Nightwatch Commands
Nightwatch custom commands for Telus Digital
Setup
This library was generated with @telus/create-library
. In order for your library to handle version management and releases automatically, please make sure you set up the NPM_TOKEN
inside the Github actions workflow, following the instructions here.
Install
npm install @telus/telus-nightwatch-commands
Configure your E2E Environment
In nightwatch.conf.js
, modify the CUSTOM_COMMANDS
and CUSTOM_ASSERTIONS
value to include the Telus nightwatch custom commands, ie
const CUSTOM_COMMANDS = [
path.join(__dirname, 'node_modules', '@telus/nightwatch-visual', 'commands'),
path.join(__dirname, 'node_modules', '@telus/telus-nightwatch-commands', 'commands')
]
const CUSTOM_ASSERTIONS = [
path.join(__dirname, 'node_modules', '@telus/nightwatch-visual', 'assertions'),
path.join(__dirname, 'node_modules', '@telus/telus-nightwatch-commands', 'assertions')
]
And set the environment variable accessibilityTestingEnabled
to true
test_settings: {
default: {
globals: {
accessibilityTestingEnabled: true
}
}
}
Use the commands in your E2E Tests
- To call the login method from your test code, pass in the url for loginUrl from any authenticated page as the follows:
browser.url('https://www.telus.com/my-telus') // example url, visit any authenticated page on Telus.
browser.url((response) => {
const loginUrl = response.value
browser.login({
username,
password,
returnUrl: 'https://www.telus.com/my-telus', // example url, use the page url you want to visit after login action
loginUrl,
oauthCookie: 'oauthCookieName', // environment specific, see note below.
sessionCookie: 'sessionCookieName',
isDevelopment: false // set to true is run locally
})
})
Note: oauth and session cookie names are specific to the environment you're trying to log into.
Environment | Value ------------ | ------------- Staging| oauthCookie = 'OAuth2TokenStage' sessionCookie = 'SessionTokenStage' Production | oauthCookie = 'OAuth2Token' sessionCookie = 'SessionToken'
- To call the Accessibility scan from your test code, call the command when the driver is on a page as the follows:
browser
.url(url, () => {
browser.assert.urlEquals(url)
})
.accessibility({
pageName: 'Hello World',
root: '#app',
rules: {
'color-contrast': { enabled: true }
},
runOnly: {
type: "tag",
values: ["wcag2a", "wcag2aa"]
},
verbose: false,
timeout: 5000
})
Note: None of the parameters are mandatory, the command can be called like this:
browser.accessibility()
- To use the custom console log command, call the command as the follow:
browser.log('Successfully logging a message.')
- To use the custom removeMyTelusSurvey command, call the command as follows:
browser.removeMyTelusSurvey()
- To use the getOneTimePasscode command, call the command as follows:
const rackspaceAuthentication = {
user: `${process.env.RACKSPACE_USER}`,
pass: `${process.env.RACKSPACE_PASS}`
}
browser.getOneTimePasscode(rackspaceAuthentication, (result) => {
browser.log(`One Time Passcode is ${result.value}`)
})
Note: Environment variables can be set locally by executing set-env.sh
script. Need for such a shippy-user access with a read policy from any My TELUS tribe.
Note: Environment can be set in an Openshift project by using the standard method used in the my-telus-e2e project.
- To use the restoreDevice command, call the command from any authenticated page as follows:
browser.restoreDevice({
ban,
sub
})
- To use the changeEmail command, call the command from any authenticated page as follows:
browser.changeEmail('newEmail')
- To use the setBillFormat command, call the command from any authenticated page as follows:
browser.changeEmail({
ban,
emailAddress
})
Github: @telus • Twitter: @telusdigital