简体   繁体   English

Ruby + Selenium-执行每个步骤后截屏

[英]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.

相关问题 如何使用Ruby在Selenium Webdriver中使用屏幕快照名称中包含日期和时间的屏幕快照? - How to take screenshot in selenium webdriver with ruby with date and time included in screenshot name? 以编程方式在Ruby中使用ScreenShot of Desktop? - Programmatically take ScreenShot of Desktop in Ruby? 谁能建议如何使用 ruby​​ selenium 截取整个网页的屏幕截图? - Can anyone suggest how to take screenshot of full webpage using ruby selenium? 如何在 Ruby 中使用 selenium-webdriver/capybara 截取完整浏览器页面及其元素的屏幕截图? - How to take a screenshot of a full browser page and its elements using selenium-webdriver/capybara in Ruby? Selenium Webdriver仅获取视口的屏幕截图 - Selenium Webdriver take screenshot of viewport only 黄瓜和红宝石:打印执行的每个步骤 - Cucumber and ruby: print every step executed Ruby Selenium屏幕快照到特定的文件位置 - Ruby Selenium Screenshot to specific File location Ruby如何执行每个循环? - Ruby how each loop is executed? Ruby:使用`.each`或`.step`,为每次迭代前移随机量 - Ruby: using `.each` or `.step`, step forward a random amount for each iteration 无法使用硒黄瓜红宝石运行自定义步骤 - Failed to run custom step with the selenium cucumber ruby
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM