phpselenium-chromedrivercodeception

Chromedriver: When is a page considered loaded?


In our project we are using Codeception to automate Chromedriver into running User Acceptance Tests. The issue we are facing is that the tests take a really long time to run. Even the most basic tests will take a minimum of 1 second.

Example:

public function testHomepage(Tester $i): void {
  $i->amOnPage('/);
  $i->see('Homepage');
}

Obviously I'm quite unhappy with the situation and want to speed this up. As we don't specify anything in our code: When is a page considered loaded by Chromedriver? Is it time-based? Or based on DOMContentLoaded or load?

Additional Information:


Solution

  • There are 3 types of Page Loading Strategies in Selenium: Normal, Eager and None.
    By the default Selenium uses normal page loading strategy. In this case Selenium blocks the programm flow until page document reariness state "complete" is reached.
    You can set the page loading strategy to "eager" to not wit for javascripts on the web page to complete loading etc.
    You can read more about the Selenium Page Loading Strategy on this document page.
    How to use it with PHP - I saw this example using this code:

    $capabilities = DesiredCapabilities::chrome();
    $capabilities->setCapability('pageLoadStrategy', 'eager');
    
    $driver = RemoteWebDriver::create($host, $capabilities);