herbs
herbs

Reputation: 67

Selenium Webdriver Exception: waitForPageToLoad is not a valid webdriver command?

I'm new to selenium testing and am trying to get my first test up and running using phpunit and selenium server 2.

I had it all setup using one of the online tutorials for automated testing, and now I'm trying to use the Firefox Selenium IDE to record the flow through the signup process on our website.

I've installed the php formatter for the IDE and exporting the recorded commands for PHPUnit, but when I run the code through PHPUnit I get:

Exception: waitForPageToLoad is not a valid webdriver command.

Any help would be much appreciated!

Many Thanks, Ian

<?php
require_once __DIR__ . '/../../../lib/php-webdriver/__init__.php';

class HomePageTest extends PHPUnit_Framework_TestCase
{
    /** 
    * @var WebDriverSession
    */
    protected $_session;

    public function setUp()
    {
        parent::setUp();
        $web_driver = new WebDriver();
        $this->_session = $web_driver->session();
    }

    public function tearDown()
    {
        $this->_session->close();
        unset($this->_session);
        parent::tearDown();
    }

    public function test_free_signup_process()
    {
        $this->_session->open('http://---.com');
        $this->_session->click("link=View Pricing");
        $this->_session->waitForPageToLoad("30000");
        $this->_session->click("link=Free Account");
        $this->_session->waitForPageToLoad("30000");
        $this->_session->type("id=first_name", "---");
        $this->_session->type("id=last_name", "---");
        $this->_session->type("id=password_tf", "---");
        $this->_session->type("id=password_confirm", "---");
        $this->_session->type("id=recaptcha_response_field", "tsTooki status:");
        $this->_session->click("id=checkbox_terms");
        $this->_session->click("css=input[type=\"submit\"]");
        $this->_session->waitForPageToLoad("30000");
        $this->_session->click("link=registration code");
        $this->_session->waitForPageToLoad("30000");
        $this->_session->type("id=code", "---");
        $this->_session->click("css=input[type=\"submit\"]");
        $this->_session->waitForPageToLoad("30000");

    }
}

Upvotes: 1

Views: 2921

Answers (2)

Joao
Joao

Reputation: 616

The Selenium 2.0 API docs are really useful for seeing what methods are available http://selenium.googlecode.com/svn/trunk/docs/api/py/api.html

Upvotes: 1

Sandro Munda
Sandro Munda

Reputation: 41030

You can use the WebDriverWait class in order to do what you want. waitForPageToLoad() is only available for Selenium version 1.

You can find the source code of the WebDriverWait class here.

Of course, the until function is the most important part.

Upvotes: 2

Related Questions