开发者

More clarity needed on the usage assertText() function?

I have written automation test cases for my application.Below is the sample code i have used for web testing.

class UserWebTestcase extends CakeWebTestCase{

var $name='UserWebTestcase';

function testLogin001()
{
    //Test if new user registration form works as intended when all the inputs are given properly.
    $this->get(Configure::read('url'));
    $this->setField('email', 'admin45@gmail.com');
    $this->setField('tmppassword', 'admin123');
    $this->setField('password_confirm', 'admin123');
    $this->clickSubmit('SUBMIT');
    $this->assertText('login');
}

}

In test case it always gives false even though the inputs for fields are correct.The error i got like this (Failed C:\xampplite\htdocs\spotchase\app\tests\cases\models\user.test.php -> UserWebTestcase -> testLogin001). Im really confused while using the assertText() method.How should i use this assertText() method and what parameters should i pass to thi开发者_如何学Pythons method. Please help.


this is not a cakephp method, but a simpletest one.

below is the actual method

   /**
     *    Will trigger a pass if the text is found in the plain
     *    text form of the page.
     *    @param string $text       Text to look for.
     *    @param string $message    Message to display.
     *    @return boolean           True if pass.
     *    @access public
     */
    function assertText($text, $message = '%s') {
        return $this->assert(
                new TextExpectation($text),
                $this->_browser->getContentAsText(),
                $message);
    }

So it seems that it is just looking for the actual text within the page, not a button or other element. maybe 'welcome bob' would be a better search

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜