Reset session between scenarios in Behat Mink. How to disabled?

1.4k Views Asked by At

We have in the company website for statistics from Facebook. Login to statistics page is using Facebook account. I have written BDD tests. Tests log into the site and test their functionality. But Facebook does not allow frequent logging (probably for safety reasons). So when they log in each scenario, it will be blocked from Facebook.

The tests are run several times a day. Facebook account is only for login to website with statistics.

I want to ask. Is it possible to disable reset session between scenarios? Or is other solution?

2

There are 2 best solutions below

2
On

The session expires after every scenario. so new scenario new session. but what you can do is behat and mink provides Background. in background you can make login. so in the start of every scenario of a feature, theres a login session made. you can also make a customized login function in feature context and than give that function name like

Background:
   Given I am logged in

else you can do easiest is

Background:
 Given I fill in "username" with "[email protected]"
 And I fill in "password" with "xyz"  

 Scenario:
    Given I am on homepage

Scenario:
   Given I am on "/support"

So you get logged in after every scenario automatically.

0
On

We used Facebook's Access Tokens to prevent our "Connect to Facebook" step to make login requests to Facebook for every scenario.

We simply retrieve the Access Token from FB's API after login, store it in a file, next time we want to connect, we check whether we got a stored "not expired" token.