2

I have a number of automated tests to date, I am accessing a login page currently 22 times with an average load time of 7s 088ms, this results in 2m 35s 937ms on this step when the remainder of my suite takes around 7minutes total.

How do I go about minimising this time with selenium, is there anything I can do with my browser capabilities/options/cache etc. I would ideally like this page loading a fair bit faster.

I am finished automating a feature and I am refactoring everything to do with it in aid of performance, best practice and effeciency.

Thank you, code wise I'm not sure if theres anything worth changing?

public static void navigateToLogin() {
    String CustomerURL= TestRunner.config.get("customerIP");        
    driver.get(CustomerURL);
    wait.until(ExpectedConditions.elementToBeClickable(LoginPage.loginButton()));       
}

I think the loading of the actual page is just slow, so waiting for my element here won't help as it just waits for the page to be loaded.

1

Considering the short duration of your entire test suite, I would suggest this pattern:

  • Create a first test that simply logs in to your application
  • Do not quit the browser/driver after this test
  • Every following test: do not create a new driver but reuse the one from your first test. Because you have the window still open you're already logged in.

This will reduce your total logins to one (assuming you only need one user).

Alternatively, look into profiles, see the answer to this question.

  • 1
    Additionally, you can work on executing your suite in parallel. This may require a effort in DevOps and mocking external services, but it can be really worth because you would be able to scaled up your suite a manifold of times, running thousands of tests in few minutes. – João Farias May 29 '17 at 9:02
  • Plus, run the test through a proxy or set up the profile to exclude images that will cut time. – CloneZero May 30 '17 at 2:34
  • @JoãoGFarias - you should put this comment in own answer. It is better than the one you added it to. – Peter M. - stands for Monica May 30 '17 at 14:02
0

An alternative way is to use a faster way to authenticate, i.e.:

  1. Login at REST API level, e.g., with REST-assured, Retrofit or any other HTTP client.
  2. Copy a session cookie from HTTP response or HTTP client cookstore to sessionCookie variable.
  3. Add sessionCookie to a browser instance (driver.manage().addCookie(sessionCookie)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.