【发布时间】:2018-07-16 23:44:57
【问题描述】:
使用下面的函数,我可以接收到最后一次执行测试的打印,但是我想学习如何在自动化执行的每个步骤中接收打印。
如何做到这一点?
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
【问题讨论】:
-
除非工具支持,否则您通常不能这样做。您将不得不存入大量“立即登录”语句。
标签: ruby rspec automation cucumber watir-webdriver