![](/img/trans.png)
[英]Ruby Cucumber AfterStep not running after every step in a scenario
[英]Cucumber and ruby: print every step executed
使用下面的功能,我可以收到測試的最后一次執行的打印,但是我想學習如何在自動化執行的每個步驟中接收打印。
如何才能做到這一點?
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
如果要在每個步驟之后執行操作,則有一個AfterStep
掛鈎-例如:
AfterStep do
browser.screenshot.save 'screenshot.png'
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.