2011-09-27 11 views
5

Su una macchina virtuale (pulito, fresco server Ubuntu 11.04) Ho creato un sito Web di test come descritto in Creating Your First Yii Application e ora voglio creare un semplice test utilizzando webdriver-test.webdriver-test è inutilizzabile

ho istituito una corretta TEST_BASE_URL in protetto/test/WebTestCase.php e creato protetto/test/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('[email protected]'), 'The is no "[email protected]" text on result page!'); 
    } 
} 

esecuzione assomiglia a questo:

[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. 

Si noti che si lamenta di setBrowserUrl() da PHPUnit_Extensions_SeleniumTestCase_Driver, che non è uguale a quello di CWebDriverTestCase.

Ho cercato di scoprire cosa sta succedendo, ma è troppo complicato per me. Sembra che i problemi con l'API di selenio vecchio e nuovo esistano insieme, ma non ne sono sicuro.

sto usando: server di

  • Ubuntu 11.04
  • Yii 1.1.8.r3324
  • WebDriver-test 1.1b
  • phpunit 3.5.15 (ripristinato come descritto in bugs.launchpad .net/ubuntu/+ source/phpunit/+ bug/701544)

Si prega di aiuto!

+0

Ho riscontrato anche questo problema. Il metodo setBrowserUrl imposta la proprietà $ baseUrl non la proprietà $ browserUrl. – jcfollower

risposta

0

È necessario chiamare il metodo setBrowseUrl() subito dopo il metodo parent :: setup() poiché il selenio richiede questo URL per risolvere i percorsi relativi nei casi di test. In questo modo puoi chiamare open ('full.url.com/someAction') o semplicemente aprire ('/ someAction') ed entrambi andrebbero alla stessa pagina.

Problemi correlati