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 PageSearchTestCase
extends SeleniumTestCase
{
31 // Verify the functionality of the 'Go' button
32 public function testPageSearchBtnGo() {
34 $this->open( $this->getUrl() .
35 '/index.php?title=Main_Page&action=edit' );
36 $this->type( SeleniumTestConstants
::INPUT_SEARCH_BOX
, "calcey qa" );
37 $this->click( "searchGoButton" );
38 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
40 // Verify no page matched with the entered search text
41 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" );
42 $correct = strstr( $source, "Create the page \"Calcey qa\" on this wiki!" );
43 $this->assertEquals( $correct, true );
45 $this->click( "link=Calcey qa" );
46 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
48 $this->type( SeleniumTestConstants
::TEXT_EDITOR
, "Calcey QA team" );
49 $this->click( "wpSave" );
50 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
53 // Verify the functionality of the 'Search' button
54 public function testPageSearchBtnSearch() {
55 $this->open( $this->getUrl() .
56 '/index.php?title=Main_Page&action=edit' );
57 $this->type( SeleniumTestConstants
::INPUT_SEARCH_BOX
, "Calcey web" );
58 $this->click( SeleniumTestConstants
::BUTTON_SEARCH
);
59 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
61 // Verify no page is available as the search text
62 $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" );
63 $correct = strstr( $source, "Create the page \"Calcey web\" on this wiki!" );
64 $this->assertEquals( $correct, true );
66 $this->click( "link=Calcey web" );
67 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
69 $this->type( SeleniumTestConstants
::TEXT_EDITOR
, "Calcey web team" );
70 $this->click( SeleniumTestConstants
::BUTTON_SAVE
);
71 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
73 // Verify saved page is opened when the exact page name is given
74 $this->type( SeleniumTestConstants
::INPUT_SEARCH_BOX
, "Calcey web" );
75 $this->click( SeleniumTestConstants
::BUTTON_SEARCH
);
76 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
78 // Verify exact page matched with the entered search text using 'Search' button
79 $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" );
80 $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." );
81 $this->assertEquals( $correct, true );
83 // Verify resutls available when partial page name is entered as the search text
84 $this->type( SeleniumTestConstants
::INPUT_SEARCH_BOX
, "Calcey" );
85 $this->click( SeleniumTestConstants
::BUTTON_SEARCH
);
86 $this->waitForPageToLoad( SeleniumTestConstants
::WIKI_TEST_WAIT_TIME
);
88 // Verify text avaialble in the search result under the page titles
89 if ( $this->isElementPresent( "Page_title_matches" ) ) {
90 $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" );
91 $this->assertContains( 'Calcey', $textPageTitle );
94 // Verify text avaialble in the search result under the page text
95 if ( $this->isElementPresent( "Page_text_matches" ) ) {
96 $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" );
97 $this->assertContains( 'Calcey', $textPageText );
99 $this->deletePage( "Calcey QA" );
100 $this->deletePage( "Calcey web" );