selenium - How to assert the current URL? -
i'm unittesting yii application phpunit
, selenium-server
.
code:
class startsurveyredirecttest extends webtestcase { public $fixtures=array( 'sessions'=>'surveysession', 'surveys' => 'survey', ); public function testactive() { $survey = $this->surveys('survey_active'); $user_id = 1; $imid = 'nl1234-9876'; $this->open('veldwerk/survey/redirect?survey_id=' . $survey->survey_id . '&user_id=' . $user_id . '&imid=' . $imid . '&' . $survey->security_parameter_name . '=' . $survey->getsecurityparametervalue() ); //assert if redirected $this->assertnotequals($this->url(),test_base_url . 'veldwerk/survey/redirect?survey_id=' . $survey->survey_id . '&user_id=' . $user_id . '&imid=' . $imid . '&' . $survey->security_parameter_name . '=' . $survey->getsecurityparametervalue() ); } }
the result when start test:
there 1 error: 1) startsurveyredirecttest::testactive method url not defined. d:\workspace\pi\framework\test\cwebtestcase.php:63 d:\workspace\pi\protected\tests\functional\startsurveyredirecttest.php:27 d:\workspace\pi\protected\tests\functional\startsurveyredirecttest.php:27 caused badmethodcallexception: method url not defined. d:\workspace\pi\framework\test\cwebtestcase.php:63 d:\workspace\pi\protected\tests\functional\startsurveyredirecttest.php:27 d:\workspace\pi\protected\tests\functional\startsurveyredirecttest.php:27
so want test if user has been redirected. thought easiest way check url turns out doesn't work? while in selenium docs , phpunit docs says can..
does yii framework not support this? or doing wrong?
instead of using url method, try property:
$this->url
i'm @ work , able check out. think proper code phpunit selenium is:
$driver->getcurrentpageurl();
so method driver instance.
Comments
Post a Comment