Menu

#19 submitFormByID - fetch the next page

open
nobody
Web Tester (1)
5
2009-04-22
2009-04-22
No

Hello. I am trying to automate our website registration and I need some help regarding fetching the next page after submitting the form. Here's the situation:

registration page: http://localhost/unit_testing/accounts/register
method=POST; action=same URL as above but with different contents if the registration is successful.

So after filling up all the required fields (using simpletest of course) and submitting the form, is there a way to fetch the succeeding page automatically? I have done this but failed, and got the main registration page, despite the fact that the registration is successful. Here's my code:

$some_textbox_variable = 'some textbox values';

$this->get('http://localhost/unit_testing/accounts/register');

if ($this->assertText('some registration page text'))
{
$this->assertTrue($this->setFieldbyName('some_textbox_name', $some_textbox_variable));

$this->assertTrue($this->submitFormById('RegisterForm'));
$this->getUrl();

if ($this->assertText('Registered')) //'Registered' is a text displayed if the registration is successful.
{ echo '<br> Success <br><br>';}
else
{echo '<br> Error <br><br>';}
;
;
}
;

And when I replace $this->getUrl(); with $this->get('http://localhost/unit_testing/accounts/register, it fetches the main registration page and not the "registration complete" page (again, both are under the same URL).

I hope somehow I made myself clear. Any help would be appreciated. Thank you.

Discussion


Log in to post a comment.