Search code examples
phpseleniumphpunitpearwampserver

PhpUnit Not waiting to load page after clicking submit


I was going through a tutorial, on PHPUNIT i got the tutorial quit well...and do some logins on my own..

But i went into the web to load a page and submit a value on a real-time page

it works fine... but the issue i have is that after entering the user key ..it submit but it wont wait for the next page

I see similar questions here but none is working-out for me

Pls Can anyone help me.

This is my code

<?php
class TestLogin extends PHPUnit_Extensions_Selenium2TestCase {
public function setUp()
{
    $this->setHost('localhost');
    $this->setPort(4444);
    $this->setBrowser('firefox');
    $this->setBrowserUrl('http://localhost/tutor');
}

public function setSpeed($timeInMilliSec)
{
    $this->setSpeed('120');
}
 /*Function to locate website*/
public function testHasLoginForm()
{
    $this->url('http://www.jamb.org.ng/DirectEntry/');/*This is the site*/
    $username = $this->byId('ctl00_ContentPlaceHolder1_RegNumber');/*Search for a name*/
            ##ctl00_ContentPlaceHolder1_txtRegNumber
    $action = $this->byId('ctl00_ContentPlaceHolder1_Reprint')->attribute('action');
    $this->byId('ctl00_ContentPlaceHolder1_RegNumber')->value('49130518ED');/*value of the textbox*/
    $jump = $this->byId('ctl00_ContentPlaceHolder1_Reprint');
    $jump->submit();
}

}
?>

Solution

  • You could use

     $this->timeouts()->implicitWait(10000);//10 seconds
    

    to set timeout of searching elements on page.

    https://github.com/sebastianbergmann/phpunit-selenium/blob/master/PHPUnit/Extensions/Selenium2TestCase/Session/Timeouts.php