Extending our ES module helper file with a custom click method
Our third option is to create a click()
method in the helpers
file. While it changes our signature, it allows us more control to recover from issues with elements:
await helpers.clickAdv(this.btnSubmit); await helpers.clickAdv(this.btnBogus);
The output now looks like this:
[0-0] ---> Clicking button[type="submit"] ... [0-0] ---> button clicked. [0-0] ---> pageSync() completed in 25 ms [0-0] ---> Clicking button[type="bogus"] ... [0-0] ---> button[type="submit"] was not clicked. [0-0] Error: Can't call click on element with selector "button[type="bogus"]" because element wasn't found
Quick tip
Unlike many coding conventions, there is no common approach for naming wrapper methods...