4 * Selenium server manager
8 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
9 * http://www.calcey.com/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * http://www.gnu.org/copyleft/gpl.html
30 Class CreateAccountTestCase
extends SeleniumTestCase
{
31 // Change these values before run the test
32 private $userName = "yourname4000";
33 private $password = "yourpass4000";
35 // Verify 'Log in/create account' link existance in Main page.
36 public function testMainPageLink() {
38 $this->click( "link=Log out" );
39 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
41 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
42 $this->assertTrue( $this->isElementPresent( "link=Log in / create account" ) );
45 // Verify 'Create an account' link existance in 'Log in / create account' Page.
46 public function testCreateAccountPageLink() {
48 $this->click( "link=Log out" );
49 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
51 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
53 // click Log in / create account link to open Log in / create account' page
54 $this->click( "link=Log in / create account" );
55 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
56 $this->assertTrue( $this->isElementPresent( "link=Create an account" ) );
59 // Verify Create account
60 public function testCreateAccount() {
62 $this->click( "link=Log out" );
63 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
65 $this->open( $this->getUrl() . '/index.php?title=Main_Page' );
67 $this->click( "link=Log in / create account" );
68 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
70 $this->click( "link=Create an account" );
71 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
73 // Verify for blank user name
74 $this->type( "wpName2", "" );
75 $this->click( "wpCreateaccount" );
76 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
77 $this->assertEquals( "Login error\n You have not specified a valid user name.",
78 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
80 // Verify for invalid user name
81 $this->type( "wpName2", "@" );
82 $this->click( "wpCreateaccount" );
83 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
84 $this->assertEquals( "Login error\n You have not specified a valid user name.",
85 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
87 // start of test for blank password
88 $this->type( "wpName2", $this->userName
);
89 $this->type( "wpPassword2", "" );
90 $this->click( "wpCreateaccount" );
91 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
92 $this->assertEquals( "Login error\n Passwords must be at least 1 character.",
93 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
95 $this->type( "wpName2", $this->userName
);
96 $this->type( "wpPassword2", $this->password
);
97 $this->click( "wpCreateaccount" );
98 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
99 $this->assertEquals( "Login error\n The passwords you entered do not match.",
100 $this->getText( "//div[@id='bodyContent']/div[4]" ) );
102 $this->type( "wpName2", $this->userName
);
103 $this->type( "wpPassword2", $this->password
);
104 $this->type( "wpRetype", $this->password
);
105 $this->click( "wpCreateaccount" );
106 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
108 // Verify successful account creation for valid combination of 'Username', 'Password', 'Retype password'
109 $this->assertEquals( "Welcome, " . ucfirst( $this->userName
) . "!",
110 $this->getText( "Welcome,_" . ucfirst( $this->userName
) . "!" ) );