I'm using Selenium, writing in Ruby. I've configured my env.rb file to save a screenshot of any failed tests that I run. The problem is it's hard to determine the scenario/step that failed as the filename is generic. I've managed to time stamp the filename using this:
After do |scenario|
if scenario.failed?
screenshot_file = "screenshot - #{Time.now.strftime('%Y-%m-%d %H-%M-%S')}.png"
page.save_screenshot(screenshot_file)
end
end
Is there a way in which I can get this filename to also pull the name of the scenario that failed so that it could be "scenario# date time.png"? I've seen a few examples online, none of which work.
Thank you
...
screenshot_file = "screenshot-#{scenario.name}-#{Time.now.strftime('%Y-%m-%d %H-%M-%S')}.png"
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.