我正在使用Cucumber和Watir Webdriver进行自动化,我想知道是否有一种方法可以清除浏览器的状态,而不是在每次运行后都将其关闭,这样我就可以使用Scenario Outline并打开浏览器的一个实例并清除示例表中列出的其他示例的浏览器状态
Scenario Outline: This is an example of what I want to achieve.
Given I visit the <Website>
Then the current page must be <page_title>
Example:
|Website|page_title|
|google| Google|
|Facebook|Welcome to Facebook|
假设就重置浏览器而言,您只需要清除cookie,就可以使用以下挂钩。
# Create a browser that will be used for all scenarios
browser = Watir::Browser.new
Before do
@browser = browser
end
# Clear the state (cookies) before each scenario
Before do |scenario|
@browser.cookies.clear
end
# Close the browser after all scenarios completed
at_exit do
browser.close
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句