Make Tests Dynamic
Many tests involve values and conditions that are not known until a test runs. Advanced functionality in PTF enables you to build tests that adapt to the application when necessary.
These test scenarios show examples of how to exploit the dynamic test features of PTF:
-
Variables
Requirement: A test that creates an entry in the application with a system-generated ID number and later has to verify that same ID number elsewhere in the application.
Solution: Store the system-generated ID to a variable in one step, and then reference that variable to verify the value in another step.
-
Conditional logic
Requirement: A test that specifies that the user click an icon to expand a section of a page, but only if that section is not already expanded.
Solution: Place the step in an If_Then construct that evaluates whether the section is expanded.
-
Scroll handling
Requirement: A test that updates an item in a grid regardless of the position of the item in the grid.
Solution: Use a Scroll action to identify the row by key rather than by position.
-
Reserved words
Requirement: A test that instructs the user to enter the date the test is processed into the application.
Solution: Use the #TODAY reserved word to enter the current date.
Dynamic steps improve the reusability and maintainability of tests.
As you are recording, be sure to make a note of situations that require dynamic handling so you can take advantage of the appropriate dynamic construct that will ensure that the test will work at runtime time.