我是 selenium 测试的新手,正在尝试使用 phpunit 和 selenium server 2 启动并运行我的第一个测试。
我使用一个自动测试在线教程完成了所有设置,现在我正在尝试使用 Firefox Selenium IDE 来记录我们网站上注册过程的流程。
我已经为 IDE 安装了 php 格式化程序并为 PHPUnit 导出了记录的命令,但是当我通过 PHPUnit 运行代码时,我得到:
异常:waitForPageToLoad 不是有效的 webdriver 命令。
如有任何帮助,我们将不胜感激!
非常感谢, 伊恩
<?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");
}
}
最佳答案
您可以使用 WebDriverWait
类来执行您想要的操作。 waitForPageToLoad()
仅适用于 Selenium 版本 1。
您可以找到WebDriverWait
类的源代码here .
当然,until函数是最重要的部分。
关于testing - Selenium Webdriver 异常 : waitForPageToLoad is not a valid webdriver command?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9774592/