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

screenshot_failed_after_scenario

Take screenshot and name it with scenario name

screenshot_failed_project

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. That way debugging gets easier. Cheers !