0

我的应用程序上有两个黄瓜功能,类似于:

Feature: Number 1  
  Background: User logs in on twitter  
    Steps  
  @log-out-remote-too
  Scenario: User logs out from local-app
    Steps  

Feature: Number 2  
  Scenario: User is logged in and is welcomed  
     Sees "welcome" inside "something"  
     Sees more stuff  

我将 webdriver/selenium 用于 firefox 和 css 选择器。总是第二个功能!失败,无论如何。我已经尝试移除钩子,所以它不会转到 twitter.com 并注销。我还尝试了一个钩子@re-login 来登录我的本地应用程序。我也尝试通过 Capybara 清除 cookie。

如果有人可以帮助我,我将非常感谢。我反对在不遵循由外向内循环的情况下开发我的应用程序但没有太多时间的想法。

PD 我注意到第二个功能的存在(即使它没有场景)使第一个功能失败。这对我来说很奇怪

4

1 回答 1

0

我终于找到了解决方法。

我写了以下钩子:

Before('@with_remote_login') do
  Capybara.current_driver = :selenium
end

我添加到需要“干净”运行的场景中

Feature: Number 1  
  Background: User logs in on twitter  
    Steps  

  Scenario: User logs out from local-app
    Steps  

Feature: Number 2 
  @with_remote_login
  Scenario: User is logged in and is welcomed  
     Sees "welcome" inside "something"  
     Sees more stuff
于 2010-11-05T06:01:05.250 回答