End to End Test
Where is the document for End-to-End test?
Why did the DOM element not change after clicking it by using the .click() function to send a click command to WebDriver?
If you can locate the DOM element correctly, but cannot access the callback function by clicking on it, it may be because the element is not shown in the viewable area of the browser.
You can use .execute() function to run a JavaScript code in browser to show the DOM element in a viewable area of the browser.
browser
.execute(
// this function is send to the browser and run in it, so it can not get any variable in you E2E test code.
// if it needs to use some values in your E2E test code, you should push them in a Array as the second param.
// it will receives these data sequentially as its parameters.
function(param1, param2) {
// 1. locate the DOM element
const div = document.getElementById(param1)
const switchBtn = div.getElementsByClassName(param2)[0]
// 2. use scrollIntoView to move the element to viewable area
switchBtn.scrollIntoView(true)
return
},
[param1, param2],
() => {
// do something else after running the JavaScript code
}
)
How do I run a specific project?
Create a new config file like
nightwatch.config.dashboard.dev.js
Change the codepath and rootpath
const codePath = path.resolve(__dirname, 'tests/e2e/dist/Dashboard/')
const rootPath = path.resolve(__dirname, 'tests/e2e/dist/')
module.exports = {
src_folders: [codePath],
output_folder: 'reports/testcase/e2e-dashboard',
custom_commands_path: path.resolve(rootPath, 'config/custom_commands'),
Add a new command in
package.json
to run it"e2e-dashboard": "rimraf ./tests/e2e/dist && babel ./tests/e2e/src --out-dir ./tests/e2e/dist && npm run dev:e2e-dashboard", "dev:e2e-dashboard": "nightwatch --config nightwatch.config.dashboard.dev.js",
Last updated
Was this helpful?