开发者

Browser sessions not cleared-up when testing two cucumber features

开发者 https://www.devze.com 2023-01-23 19:02 出处:网络
I have two cucumber features on my app that resembles something like: Feature: Number 1 Background: User logs in on twitter

I have two cucumber features on my app that resembles something like:

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  

I am using webdriver/selenium for firefox and the css selector. The second feature always! fails, no matter what. I have tried removing the hook so it does not go to twitter.com and logs out. I have tried also a hook @re-login for logging in on my local app. I have also tried clearing the cookies through Capybara.

I would really thank if someone could help me on this. I am resisting the idea to develop my app without following the outside-in cycle but have not so much time.

PD I have noticed that the presence of the second feature (even if it has no scenarios on it) 开发者_开发知识库makes the first feature fail. This is weird to me


I finally found a workaround for this.

I wrote the following hook:

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

which I added to the scenarios which needed to run "cleanly"

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
0

精彩评论

暂无评论...
验证码 换一张
取 消