Search code examples
seleniumcaptchacucumber-jvmbrowser-automation

What are the pros and cons to use same session to run your Cucumber-JVM selenium tests in browser?


I am using Cucumber-JVM for my functional automated testing. Underneath code is selenium-java.

My application uses google authentication. If I have 50 tests in my suite and I run my tests, sometimes I face CAPTCHA in login steps and all my tests start failing.

One way to solve this problem forever is if somehow I mock/setup login using cookies or if I retain the browser session.

I know retaining the browser session could result in other different problems and it is always recommended to start your tests from clean browser tests.

Has anyone ever faced this issue and can help me with this? What may go wrong if i use same browser session for all my cucumber scenarios?


Solution

  • I think the best approach would be to work with your developers and deploy this application without Captcha on your test environments. That would be the cleanest way to get things done.

    Your approach:

    Pros:

    1. Less execution time (no login needed)
    2. quick and dirty fix

    Cons:

    1. quick and dirty fix
    2. What happens when your session expire? All your test will fail again...
    3. You'll have to setup a browser profile with a specific session. What if you're testing on 5 different browsers?