End-to-end test environment
The test-framework
package contains reusable files to help you set up a
test environment with TestCafe, and to help you to develop end-to-end test scripts.
End-to-end test helper files
The end-to-end test helper files in test-framework
are designed to operate best within a page object framework structure for your end-to-end automation suite.
End-to-end test initial setup and configuration
Create your directory structure and index.js file.
Page object development and best practices
The page object model design pattern for building UI automation frameworks is our recommended practice. A page object is an object-oriented class that is built to represent the individual pages in the application under test. These representations offer an interface from which your test scripts can interact with any UI element that is associated with that page similarly to how a user would interact with them.
The pageObject class
The PageObject.js
file in the test-framework
package provides an interface from which you can easily create page objects for use in your end-to-end framework. When you create page objects, you can use PageObject
constructor
parameters to automatically generate methods that are commonly used by page objects during automation.
Adding custom behavior to your page objects
You can add custom behavior to your page objects. For example, a specific click action, or a specific series of instructions to run for an automated task in your end-to-end test scripts.
Building, exporting and configuring your page objects
Build, export, and configure your page objects so you can import and use them in your end-to-end test scripts.
Writing end-to-end scripts
Now that your page objects are developed and your end-to-end framework is configured to use the test-framework
package, you are ready to start writing test scripts that bring everything together. The code samples are developed with testcafe
as the leading framework.
Running end-to-end tests
It is straightforward to run your tests with testcafe
by using a single npm
script and a number of custom-set options.