0

How can I reset the session for each scenario? I am using cucumber, watir-webdriver, parallel_tests gem and ruby. It runs with 8 threads but treats each thread as one long scenario. On my local this is fine but when sending it to sauce labs I want have each scenario to be its own session so I can update pass/fail/etc. This is what I have tried:

After do |scenario|
  browser.driver.instance_variable_get('@bridge').deleteAllCookies
end

This did not work unfortunately.

  • Note that Watir has an API for clearing cookies - `browser.cookies.clear`. Though from a quick glance, will give the same result. How is the deleting of cookies not working right now? Are the cookies not being deleted? – Justin Ko Aug 25 '15 at 14:13

2 Answers2

0

See Is there a cucumber hook to run before and after each feature So no, you can't do that. You can however, use:

After('@my_feature_tag') do
  #reset 
end

to reset it after certain tags, or

After do |scenario|
 #reset
end

to reset it every scenario.

Community
  • 1
  • 1
dgmora
  • 1,239
  • 11
  • 27
  • Thanks @dgmora. I should have been more clear. I am deleting all cookies after the scenario but that doesn't seem to do the trick. I have updated my question. –  Aug 24 '15 at 19:08
0

I was closing the browser and clearing the cookies but that did not work. Found an example of splitting scenarios before using parallel_tests that did the trick for me. Thanks for those that posted responses.