Adding custom code execution to the test project
As we already learned from the Chapter 2, Exploring TestCafe Under the Hood, TestCafe lets you write code to be executed on the tested page; this way you can get web elements, URLs, and so on. Special kinds of functions are used to execute your code on the client side in the browser:
Selector
: To obtain any DOM elements.ClientFunction
: To obtain any data from the client side.
These functions should be used in the same way as ordinary async functions, and you can use parameters to pass data inside such functions. The selector API provides methods and properties to select elements on the page and get their state.
To keep a proper structuring of the tests, it is recommended to group them by fixture. So, let's add a Redmine entities creation tests
fixture and a Create a new project
test to see how custom code execution works:
const { Selector, ClientFunction } = require('testcafe');const { stamp ...