3

我正在使用 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|
4

2 回答 2

3

假设在重置浏览器方面,只需要清除cookies,可以使用以下钩子。

# 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
于 2013-11-05T18:31:09.187 回答
0

你在谈论 tITEL 因为如果你在那里有任何教程并且很容易尝试在 google 中输入更改标题的 thw 状态

于 2013-11-04T13:42:47.330 回答