DRY Selenium tests – Log In by pre-populating cookies or creating a Local Storage entry in the browser

To put it simply: it does not make sense to log in by entering your test user’s login and password every time you run a test. Most E2E tests start with a @BeforeTest method which executes some test setup. It usually consists of logging in and then entering a certain part of your application.

Instead of executing:
public void setup() { new LoginPage.goTo().logInAs(“john”,”password”);}

public void setup() {TestUtils.setBrowserCookieFor(“john”);}

reference: https://saucelabs.com/resources/articles/speed-up-your-selenium-tests

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s