Answer the question
In order to leave comments, you need to log in
How to wait for a page to fully load in Selenium php?
Hello.
There is a parser written in Selenium WebDriver. Link to it is here .
Initially, everything worked fine, after the changes on the site, the page began to load for a long time and the main information was loaded by Ajax. And at first, only a block with a name and a preloader.
And it turns out that not the entire html code of the page is given to me, but only the block with the preloader.
The documentation says that you can wait 10 seconds with a check interval like this:
$driver->wait(10, 1000)->until(
function () use ($driver) {
$elements = $driver->findElements(WebDriverBy::cssSelector('#a-match'));
return count($elements) == 1;
},
'Error element'
);
Answer the question
In order to leave comments, you need to log in
where you configure the driver, set the wait ( read )
Not strong in php, but you need something like this:
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
So you set the time for the driver to wait for your condition to be met (if the condition is met earlier, get it earlier) . The
next question is how long are you willing to wait (sometimes people set 60 seconds).
If there are Ajaxes, then just like this: $driver->wait(10, 1000)->until(
WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::id('first_name'))
);
that is, you have to wait until a certain element reappears, or until the preloader disappears after Ajax, and then what to do.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question