在虚拟机(干净,新鲜的Ubuntu服务器11.04)上,我创建了一个测试网站,如Creating Your First Yii Application中所述,现在我想使用webdriver-test创建简单测试。网络驱动程序测试不可用
我设置适当的TEST_BASE_URL在保护/测试/ WebTestCase.php和创建保护/测试/功能/ MySimpleTest.php
<?php
Yii::import('ext.webdriver-bindings.CWebDriverTestCase');
class MySimpleTest extends CWebDriverTestCase {
protected function setUp() {
parent::setUp('192.168.57.1', 4444, 'firefox');
}
public function testMySite() {
$this->get(TEST_BASE_URL);
$qElem = $this->findElementBy(LocatorStrategy::linkText, 'Users');
$this->assertNotNull($qElem, 'There is no "Users" link!');
$qElem->clickAndWait();
$this->assertTrue($this->isTextPresent('[email protected]'), 'The is no "[email protected]" text on result page!');
}
}
运行它看起来像这样:
[email protected]:/var/www/test/protected/tests$ phpunit functional/MySimpleDbTest.php
PHPUnit 3.5.15 by Sebastian Bergmann.
E
Time: 5 seconds, Memory: 5.25Mb
There was 1 error:
1) MySimpleTest::testMySite
PHPUnit_Framework_Exception: setBrowserUrl() needs to be called before start().
/opt/yii-1.1.8.r3324/framework/test/CWebTestCase.php:61
/var/www/test/protected/extensions/webdriver-bindings/CWebDriverTestCase.php:156
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
注意它正在抱怨来自PHPUnit_Extensions_SeleniumTestCase_Driver的setBrowserUrl(),它与CWebDriverTestCase中的不一样。
我试图找出发生了什么,但对我来说太复杂了。它看起来像新旧硒API存在的问题,但我不确定。
我使用:
- Ubuntu的服务器11.04
- YII 1.1.8.r3324
- webdriver的测试1.1B
- 如bugs.launchpad描述的PHPUnit 3.5.15(修复.net/ubuntu/+ source/phpunit/+ bug/701544)
请帮忙!
我也有这个问题。 setBrowserUrl方法设置$ baseUrl属性而不是$ browserUrl属性。 – jcfollower