[英]Ruby + Selenium - Take a screenshot with each step executed
I want to take a screenshot with each step executed, the code below is taking a screenshot during the entire execution. 我想在执行每个步骤时都截图,下面的代码在整个执行过程中都截图。
How to fix this? 如何解决这个问题?
HOOKS.RB 挂钩
AfterStep do
browser.screenshot.save 'screenshot.png'
encoded_img = @browser.driver.screenshot_as(:base64)
embed("data:image/png;base64,#{encoded_img}",'image/png')
end
ENV.RB ENV.RB
#encoding: utf-8
require 'rspec/expectations'
require 'watir'
require 'rspec'
require 'json'
require 'magic_encoding'
RESULT EXPECTED 预期结果
I discovered that the environment that I was using was with outdated gems, I solved this with the gem update
command. 我发现我所使用的环境包含过时的gem,我使用gem update
命令解决了这个问题。
After refreshing the gems, screenshots are now taken correctly. 刷新宝石后,现在可以正确拍摄屏幕截图了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.