Phpunit webdriver测试无法使用
在一台虚拟机(干净、新鲜的Ubuntu服务器11.04)上,我创建了一个测试网站,如中所述,现在我想使用创建一个简单的测试网站 我在protected/tests/WebTestCase.php中设置了适当的TEST\u BASE\u URL,并创建了protected/tests/functional/MySimpleTest.phpPhpunit webdriver测试无法使用,phpunit,yii,webdriver,selenium-webdriver,Phpunit,Yii,Webdriver,Selenium Webdriver,在一台虚拟机(干净、新鲜的Ubuntu服务器11.04)上,我创建了一个测试网站,如中所述,现在我想使用创建一个简单的测试网站 我在protected/tests/WebTestCase.php中设置了适当的TEST\u BASE\u URL,并创建了protected/tests/functional/MySimpleTest.php <?php Yii::import( 'ext.webdriver-bindings.CWebDriverTestCase' ); class MySi
<?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( 'test1@example.com' ), 'The is no "test1@example.com" text on result page!' );
}
}
注意,它在抱怨PHPUnit_Extensions_SeleniumTestCase_驱动程序中的setBrowserUrl(),这与CWebDriverTestCase中的不同
我想知道发生了什么事,但对我来说太复杂了。看起来新旧selenium API同时存在问题,但我不确定
我正在使用:
- Ubuntu服务器11.04
- yii 1.1.8.r3324
- webdriver测试1.1b
- phpunit 3.5.15(按照bug.launchpad.net/ubuntu/+source/phpunit/+bug/701544中的描述进行修复)
请帮忙 您需要在parent::setup()方法之后调用setBrowseUrl()方法,因为selenium需要此url来解析测试用例上的相对路径。因此,通过这种方式,您可以调用open('full.url.com/someAction')或只调用open('/someAction'),两者都将转到同一页面。我也遇到了这个问题。setBrowserUrl方法设置$baseUrl属性,而不是$browserUrl属性。
etam@ubuntu:/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.