1

Background: A web page takes about 2+ minutes to load. Problem: I am currently automating acceptance test using Capybara, Rspec, Selenium. Visit(URL) -- waits for all the way until the page is loaded or times out.

I extended the timeout but it causing increased the execution time of the test.

Is there any way I can visit URL without having to wait for the full page to load. I do not need the whole page to load. All I care about is to validate if the user is logged in or not by expecting user first name + last name on the header of the page.

0

Using chromedriver you can use page load strategy to define your behaviour test when waiting for the page.

For more information: https://w3c.github.io/webdriver/#navigation

To select the page load strategy you can use something like this:

Selenium::WebDriver::Remote::Capabilities.chrome(page_load_strategy: 'none')

Unfortunantly 'eager' mode will just be available after Chrome's version 77

Until this you can wait for the page readyStage property as a workaround

page.execute_script('return document.readyState') == 'interactive'

Hope it'll help you

1

What visit waits until is determined by the specific driver used (chromedriver, geckodriver, etc) and the page load strategy that driver is configured to use - https://w3c.github.io/webdriver/#navigation. Unfortunately, if you're using Chrome the "interactive" page load strategy won't be supported until Chrome/chromedriver 77 but you could configure a driver with the "none" strategy for use in the few tests where you need it.

  • Thank you for answering! currently using chromedriver. – Estefania Jul 17 at 4:18

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.