views:

90

answers:

1

I am trying to get Selenium RC up and running for doing some automated testing on my website. I am finding that I constantly want to verify that I haven't broken any features, and manual testing is starting to become tiresome.

However, I can't seem to get Selenium RC to work with WaitForPageToLoad.

I tried copying the basic example that they give in the selenium documentation, but the test always gets stuck at: $this->waitForPageToLoad("30000"); I can see that it gets that far in the window that it brings up and that the page appears to have loaded correctly (we are at a google search result page). But the test fails with a timeout.

require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

/**
 * Description of Test
 *
 * @author brian
 */
class Test extends PHPUnit_Extensions_SeleniumTestCase {

    function setUp() {
        $this->setBrowser("*safari");
        $this->setBrowserUrl("http://www.google.com/");
    }

    function testMyTestCase() {
        $this->open("/");
    $this->type("q", "selenium rc");
    $this->click("btnG");
    $this->waitForPageToLoad("30000");
    $this->assertTrue($this->isTextPresent("Results * for selenium rc"));
    }
}

What is even more interesting is that if I refresh the page when it is waiting, everything continues on as expected. So it would appear as though the waitForPageToLoad isn't realizing that the page has already loaded.

+4  A: 

The example in the Selenium RC documentation is obsolete. Google changed the way their home page worked quite a while ago, and it is no longer a simple HTML page. Pressing the search button is now an AJAX-type operation that sends the search request and gets back a JSON response that is processed by the JavaScript code in the page. So the page never is re-loaded, and WaitForPageToLoad() eventually times out.

Ross Patterson
Thanks! I didn't realize that was the problem. I figured that their example would be up to date. Everything appears to be working now.
Brian