Behat Mink webdriver session is destroyed after every feature in a suite

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 02:40:10

问题


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.


回答1:


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 ...



回答2:


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



来源:https://stackoverflow.com/questions/12614524/behat-mink-webdriver-session-is-destroyed-after-every-feature-in-a-suite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!