When creating Acceptance tests with PhpUnit and its Selenium2 extension, I am attempting to utilize the execute method within the PHPUnit_Extensions_Selenium2TestCase class to run Javascript code that checks if the document is fully loaded.
Here is an example test I tried:
$this->waitUntil(function (LoginTest $driver) {
if ( $driver->execute( 'return document.readyState;' ) == 'complete' ) {
return true;
}
return null;
}, 10000);
However, I encountered the following error:
InvalidArgumentException: The JSON parameters must be an array, or a NULL value in case they are not required.
Realizing that it expects an array, I then attempted this approach:
$this->waitUntil(function (LoginTest $driver) {
if ( $driver->execute( ['return document.readyState;'] ) == 'complete' ) {
return true;
}
return null;
}, 10000);
But now I'm facing a different error:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: java.util.ArrayList cannot be cast to java.util.HashMap
Could you advise on the correct way to use the execute method?