dpxnh80648
dpxnh80648
2012-09-27 05:17
浏览 65
已采纳

Behat Mink webdriver会话在套件中的每个功能之后被销毁

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.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用带有selenium webdriver for php的BDD和Mink自动化sugarcrm功能。 我已经正确安装了它们并能够运行behat和mink。 例如,检查sugarcrm上的登录是否为一个特征。

现在问题是当我创建两个特征文件时说login.feature和setup.feature。 Behat在浏览器中成功自动化登录过程但是一旦切换到需要从先前功能维护登录会话的setup.feature,它就会破坏会话并返回登录窗口。 因此,第二个功能测试总是失败。

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

只是告诉你们那些人 我也在一个功能文件中尝试了它们作为不同的场景,但没有运气,因为同样的事情是haapening

如果有人知道的话请帮帮我。 < / DIV>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • drqvsx1228
    drqvsx1228 2012-09-27 10:31
    已采纳

    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 ...
    
    点赞 评论
  • duanpo1498
    duanpo1498 2013-01-18 21:37

    I completely agree with Jakub Zalas answer

    Still if your goal is to get rid of duplicate code declaring background in every feature i believe you can use hooks to perform all required actions before each scenario

    点赞 评论

相关推荐