1

I am doing a test of scenarios like this:

  1. access protected link (driver.get(link))
  2. redirect to login page
  3. write username/pass and press login button
  4. redirect to initial page

The problem is that after login the "initial page" is taking too much to load. I only want to make a simple check on the page (1/2 elements) but it takes to long and I am losing time doing this.

So does anybody know a way to get around waiting for the page to load? (the elements I want are loaded fast +plus I wait for them after I get the context of the page)

I thought about taking the link from the button and do driver.navigate.to(link_button) but I want to avoid this.

1 Answers1

3

One thing you can do to not wait for the whole page to load is to:

  • specify "eager" or "none" page load strategy (normal is default)

    normal: This stategy causes Selenium to wait for the full page loading (html content and subresources downloaded and parsed).

    eager: This stategy causes Selenium to wait for the DOMContentLoaded event (html content downloaded and parsed only).

    none: This strategy causes Selenium to return immediately after the initial page content is fully received (html content downloaded).

  • use WebDriverWait to wait for the element you need to check in this specific test scenario

And/or you can re-structure your tests and avoid navigating to the page when not logged in - e.g. going to login first to login -> navigate to the desired page.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195