测试两个 Cucumber 功能时,浏览器会话未清除

发布于 2024-09-30 12:24:31 字数 611 浏览 3 评论 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 for firefox 和 css 选择器。永远是第二个功能!失败了,无论如何。 我尝试删除该钩子,这样它就不会转到 twitter.com 并注销。 我还尝试了一个钩子@re-login来登录我的本地应用程序。 我也尝试过通过水豚清除cookies。

如果有人能在这方面帮助我,我真的很感激。我拒绝在不遵循由外而内循环的情况下开发应用程序的想法,但没有那么多时间。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坏尐絯℡ 2024-10-07 12:24:31

我终于找到了解决这个问题的方法。

我编写了以下钩子:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文