Screenshots

Screenshots are helpful for the below reasons:

  • Know on which page of web application the failure occured
  • Narrow down in terms of finding the root cause of failure
  • Audit purposes in financial firms to take screenshots and save them
  • Just take screenshots for later analysis (for whatever reasons)

Command to take screenshot

Take screenshot when scenario fails

Modify the below code in “hooks.rb” file in the project

scenario_failed

Take screenshot and name it with scenario name

 

explicit_scenario_failed

Embed the screenshot taken above inline in html report

 

click_failed_screenshot

Closing Thoughts:

As per above, we have taken screenshots ONLY when scenario fails, however with the commands above, you can always take screenshot wherever in the control flow. Embedding the screenshots in-line in html report makes it easier for us to analyse and connect “where” the scenario failed and also “which line of code” did it fail against. That way debugging gets easier. Cheers !