I have quite a fundamental problem that none of my selenium phpunit tests pass unless I step through them manually in debug view, which is obviously a bit of an inconvenience! I'm running a local selenium server from the following jar file and executing the phpunit test from within Zend Studio 8.
selenium-server-standalone-2.0b2.jar
I can't seem to find anything relevant on google or by searching here, so I assume I must be doing something wrong. Here is an example method I call from the start of most test methods in order to log in.
protected function login() {
$this->open ( "/login.php" );
try {
$this->waitForPageToLoad ( "30000" );
$this->type ( "username", self::MA_USERNAME );
$this->type ( "password", self::MA_PASSWORD );
$this->click ( "//input[@value=' Login ']" );
$this->waitForPageToLoad ( "60000" );
$this->assertFalse( $this->isTextPresent( "Login details supplied are invalid." ) );
} catch ( PHPUnit_Framework_AssertionFailedError $e ) {
array_push ( $this->verificationErrors, $e->toString () );
}
}
If I just press 'run' and let it go then it doesn't even fill in the fields or submit the form, so I'm assuming it hasn't waited for the page to load despite having the waitForPageToLoad() call. Stepping through manually works perfectly. Can anyone suggest how to fix this? Thanks.
Seems like Selenium is executing commands way to quick. I had the same problem.
The way I fixed my problem was to use the function setSpeed($timeInMilliSec)
In php:
$this->setSpeed('120');
So in your function, try this:
protected function login() {
$this->open ( "/login.php" );
$this->setSpeed('120');
try {
$this->waitForPageToLoad ( "30000" );
$this->type ( "username", self::MA_USERNAME );
$this->type ( "password", self::MA_PASSWORD );
$this->click ( "//input[@value=' Login ']" );
$this->waitForPageToLoad ( "60000" );
$this->assertFalse( $this->isTextPresent( "Login details supplied are invalid." ) );
} catch ( PHPUnit_Framework_AssertionFailedError $e ) {
array_push ( $this->verificationErrors, $e->toString () );
}
}
Hope this fixes your problem