My problem: I am running phpunit with Selenium to test a website on a server that is on the other side of the world. So, there is a delay of a few seconds for things like clicking on a tab or a new page. I start Selenium Server with Chromedriver. eg.
public function setUp()
{
$this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
$this->setPort(4444); // set port # for connection to selenium server
$this->setBrowser('chrome'); // set the browser to be used
$this->setBrowserUrl('https://www.*.com'); // set base URL for tests
$this->prepareSession()->currentWindow()->maximize(); // Maximize the window when the test starts
$this->timeouts()->implicitWait(30000); // Wait up to 30 seconds for all elements to appear
}
public function testLoginToeSeaCare(){
$this->timeouts()->implicitWait(10000); // Wait up to 10 seconds for all elements to appear
$url = 'https://www.*.com';
$loginName = 'Ned';
$loginPassword = 'Flanders';
$this->url($url); // Load this url
$this->timeouts()->implicitWait(30000); // Wait up to 30 seconds for all elements to appear
$username = $this->byId('username'); // Search page for input that has an id = 'username' and assign it to $username
$password = $this->byId('password'); // Search page for input that has an id = 'password' and assign it to $password
$this->byId('username')->value($loginName); // Enter the $loginName text in username field
$this->byId('password')->value($loginPassword); // Enter the $loginPassword in password field
$this->byCssSelector('form')->submit(); // submit the form
$tab1Link = $this->byLinkText("Tab1"); // Search for the textlink Tab1
$this->assertEquals('Tab1', $tab1Link->text()); // assert tab text is present
$this->timeouts()->implicitWait(10000); // Wait up to 10 seconds for all elements to appear
$tab2Link = $this->byLinkText("Tab2");
$tab2Link->click(); // Click 'Tab2' tab
}
There is an error reported when the above is run and I capture it in an xml file: ********::testSearch PHPUnit_Extensions_Selenium2TestCase_WebDriverException: unknown error: Element ... is not clickable at point (430, 139). Other element would receive the click: (Session info: chrome=57.0.2987.133) (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233)
What I am trying to do is to wait for the DOM to be completely loaded before clicking on a button. But I get the above error intermittently. Does anyone know a way around this?? Its driving me nuts!!