使用下面的功能,我可以收到上次执行测试的打印件,但是我想学习如何在自动化执行的每一步中接收打印件。
如何做到这一点?
env.rb
# encoding: utf-8
require 'watir'
require 'rspec'
hooks.rb
# coding: utf-8
require 'json'
require 'magic_encoding'
require 'win32console'
require 'watir'
require 'rspec'
browser = Watir::Browser.new
browser.driver.manage.window.maximize
Before do
@browser
@browser = browser
end
After do |_scenario|
browser.screenshot.save 'screenshot.png'
embed 'screenshot.png', 'image/png'
end
login.rb
given("que estou na tela de login") do
@browser.goto "url"
#I want a screenshot of this step
end
答案 0 :(得分:0)
如果您想在每个步骤后执行操作,则会有一个AfterStep do
browser.screenshot.save 'screenshot.png'
end
挂钩 - 例如:
override func viewDidLayoutSubviews()
{
if(deviceWidthSE)
{
self.viewTopCon.constant = 75
}
else
if(deviceWidth8)
{
self.viewTopCon.constant = 85
}
else
if(deviceWidth8Plus)
{
self.viewTopCon.constant = 105
}
}