套件中的每个功能都被破坏之后,Behat Mink Webdriver会话将被破坏 [英] Behat Mink webdriver session is destroyed after every feature in a suite

查看:47
本文介绍了套件中的每个功能都被破坏之后,Behat Mink Webdriver会话将被破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Behat BDD和Mink以及用于php的硒webdriver来实现sugarcrm功能的自动化.我已经正确安装了它们,并且能够同时运行behat和貂皮.例如,将sugarcrm上的登录作为一项功能进行检查.

现在的问题是当我创建两个功能文件时,例如login.feature和setup.feature. Behat成功地实现了浏览器中登录过程的自动化,但是一旦切换到setup.feature,则需要从以前的功能中维护登录会话,它将破坏会话并返回到登录窗口.因此,第二项功能测试始终会失败.

我如何维护功能套件中每个功能的会话?

只是告诉大家我也曾在一个功能文件中尝试过它们作为不同的场景,但是没有运气,因为同一件事正在恶化

如果有人知道,请帮助我.

解决方案

功能和方案应独立.这是预期的行为,如果您在一种情况下执行某项操作,则状态不会传递到下一种情况.

我不确定您要达到的目标,但是您肯定做错了什么.

如果您需要在每种情况下都登录用户,只需编写一个meta步骤即可执行所有必要的操作:

Given I am logged in

您可以使用步骤执行链或直接调用Mink./p>

如果功能文件中的每种情况都需要登录,则可以使用背景:

Background:
    Given I am logged in

Scenario: Listing users
    Given ...

Scenario: Removing a user
    Given ...

I am trying to automate sugarcrm functionality with behat BDD and Mink with selenium webdriver for php. I have properly installed both of them and able to run behat and mink together. for example checking login on sugarcrm as one feature.

Now the problem is when i create two feature file say login.feature and setup.feature. Behat successfully automate login process in browser but as soon as it switches to setup.feature which require login session to be maintained from previous feature, it destroy session and comes back to login window. therefore, second feature test is always failing.

How i can maintain session for every feature in my feature suite?

Just to tell you guys that i have also tried them in a single feature file as different scenario but with no luck as the same thing is haapening

Please Help me if anyone knows about it.

解决方案

Features and scenarios should be independent. It is THE expected behaviour that if you do something in one scenario, the state is not carried to the next one.

I'm not sure what you're trying to achieve but you definitely doing something wrong.

Edit:

If you need to log user in before every scenario simply write a meta step which will perform all the necessary operations:

Given I am logged in

You could use step execution chaining or simply call Mink directly.

If every scenario in your feature file requires logging in you can use background:

Background:
    Given I am logged in

Scenario: Listing users
    Given ...

Scenario: Removing a user
    Given ...

这篇关于套件中的每个功能都被破坏之后,Behat Mink Webdriver会话将被破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆