Behat/Mink — Issue #191: Selenium driver's click() method doesn't wait till page loads
Author: jakzal
Created: 2012-02-12 21:02:26+00:00
State: open

Current implementation of [click()](https://github.com/Behat/Mink/blob/develop/src/Behat/Mink/Driver/SeleniumDriver.php#L441) method for SeleniumDriver is:

```php
public function click($xpath)
{
$this->browser->click(SeleniumLocator::xpath($xpath));
$readyState = $this->browser->getEval('window.document.readyState');

if ($readyState == 'loading' || $readyState == 'interactive') {
$this->browser->waitForPageToLoad($this->timeout);
}
}
```

From my observations page doesn't manage to load if a clicked object was a link (and new page needs to be loaded). `$readySstate` is neither 'loading' nor 'interactive'. Therefore `waitForPageToLoad()` never gets called.

Calling `waitForPageToLoad()` would fix the issue. I'm not sure if we can do that though. Checking the document state was put there for a reason (?).