Are you lost with locating the web elements while debugging your test script? The highlight feature of Qxf2’s Page Object Model framework helps you to debug locators by giving a visual clue. This blog post will guide you with the steps involved in using the highlight feature of Qxf2’s Page Object Model framework in your test script.
The highlight feature in our framework will give you a visual clue of the test flow. On enabling the highlight feature, the web elements under test will be highlighted during test execution. A locator might match with exactly a single web element on a web page. It might match with multiple web elements as well like in the case of reading data from a table. The highlighting feature has been implemented for both scenarios.
Steps to invoke the highlight feature in your test script are:
- Fork and clone the Qxf2’s Page Object Model framework and follow the setup instructions detailed out in the Readme.md file. To jump start with creating your new project with our framework, you can refer to this blog post: How to start using the Qxf2’s framework with a new project
- Edit your test script to turn on or off the highlight feature as needed. Call the turn_on_highlight() method to enable the highlighting feature. Similarly, call the turn_off_highlight() method to disable the highlighting feature of the framework in your test script. The test script namely, test_example_form.py in our framework has been updated to include this feature
- Run your test script and you will have a visual highlighting that shows the flow of your test. A sample run of our test script namely, test_example_form.py is as follows:
Open Git Bash and execute pytest -k example_form command. You will see the visual highlighting of the web element under test as in the image below.
I hope this post helps you with debugging your test script!