【发布时间】:2013-12-19 22:00:02
【问题描述】:
我有两个问题:
- 我在 PHPUnit 和 Selenium 中创建了很多测试用例,但我想将它们作为一个组运行,而不是一次运行 1 个。
- 在多个浏览器上运行它们的最佳方式是什么。我已经查找了使用 webdriver 的示例,但不确定如何使用
我的 2 个测试用例是:
第一:
class AdminUserViewReqTabOptions extends PHPUnit_Extensions_Selenium2TestCase{
public function setUp()
{
$this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
$this->setPort(4444); // set port # for connection to selenium server
$this->setBrowser('firefox'); // set the browser to be used
$this->setBrowserUrl(''http://www.example.com'); // set base URL for tests
}
public function testShowRequestsOnHold()
{
$this->url('index.php'); // Set the URL to test
// check for the existence of the string 'Show requests on hold'
$this->assertRegExp( '/Show requests on hold/i', $this->source() );
}
public function testShowOnlyPendingApprovals()
{
$this->url('index.php'); // Set the URL to test
// check for the existence of the string 'Show requests on hold'
$this->assertRegExp( '/Show only Pending Approvals/i', $this->source() );
}
}
第二:
class AdminUserViewReqTabOptions extends PHPUnit_Extensions_Selenium2TestCase{
public function setUp()
{
$this->setHost('localhost'); // Set the hostname for the connection to the Selenium server.
$this->setPort(4444); // set port # for connection to selenium server
$this->setBrowser('firefox'); // set the browser to be used
$this->setBrowserUrl('http://www.example.com'); // set base URL for tests
}
public function testDisplayServer()
$this->url('index.php'); // Set the URL to test
// check for the existence of the strin 'All Open'
$this->assertRegExp( '/Server: Development/i', $this->source() );
}
}
【问题讨论】:
标签: php selenium selenium-webdriver phpunit