开发者

webdriver-test is unusable

On a virtual machine (clean, fresh Ubuntu server 11.04) I created a test website as described in Creating Your First Yii Application and now I want to create simple test using webdriver-test.

I set up proper TEST_BASE_URL in protected/tests/WebTestCase.php and created protected/tests/functional/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( 'test1@example.com' ), 'The is no "test1@example.com" text on result page!' );
    }
}

Running it looks like this:

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.

Notice that it's complaining about setBrowserUrl() from PHPUnit_Extensions_SeleniumTestCase_Driver, which is not the same as one from CWebDriverTestCase.

I tried to find out what's going on, but it's too complicated to me. It looks like problems with old and new selenium API existing together, but I'm not sure about it.

I'm using:

  • Ubuntu server 11.04
  • yii 1.1.8.r3324
  • webdriver-test 1.1b
  • phpunit 3.开发者_如何学Python5.15 (repaired as described in bugs.launchpad.net/ubuntu/+source/phpunit/+bug/701544)

Please help!


You need to call the setBrowseUrl() method right after the parent::setup() method because selenium requires this url to resolve relative paths on your test cases. So this way you could call open('full.url.com/someAction') or just open('/someAction') and both would go to the same page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜