MediaWiki  REL1_19
PageSearchTestCase.php
Go to the documentation of this file.
00001 <?php
00002 
00030 class PageSearchTestCase extends SeleniumTestCase {
00031 
00032     // Verify the functionality of the 'Go' button
00033     public function testPageSearchBtnGo() {
00034 
00035         $this->open( $this->getUrl() .
00036                 '/index.php?title=Main_Page&action=edit' );
00037         $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "calcey qa" );
00038         $this->click( "searchGoButton" );
00039         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00040 
00041         // Verify  no page matched with the entered search text
00042         $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" );
00043         $correct = strstr ( $source, "Create the page \"Calcey qa\" on this wiki!" );
00044         $this->assertEquals( $correct, true );
00045 
00046         $this->click( "link=Calcey qa" );
00047         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00048 
00049         $this->type( SeleniumTestConstants::TEXT_EDITOR , "Calcey QA team" );
00050         $this->click( "wpSave" );
00051         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00052 
00053     }
00054 
00055     // Verify the functionality of the 'Search' button
00056     public function testPageSearchBtnSearch() {
00057 
00058         $this->open( $this->getUrl() .
00059                 '/index.php?title=Main_Page&action=edit' );
00060         $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
00061         $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00062         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00063 
00064         // Verify  no page is available as the search text
00065         $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" );
00066         $correct = strstr ( $source, "Create the page \"Calcey web\" on this wiki!" );
00067         $this->assertEquals( $correct, true );
00068 
00069         $this->click( "link=Calcey web" );
00070         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00071 
00072         $this->type( SeleniumTestConstants::TEXT_EDITOR, "Calcey web team" );
00073         $this->click( SeleniumTestConstants::BUTTON_SAVE );
00074         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00075 
00076         // Verify saved page is opened  when the exact page name is given
00077         $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey web" );
00078         $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00079         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00080 
00081         // Verify exact page matched with the entered search text using 'Search' button
00082         $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" );
00083         $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." );
00084         $this->assertEquals( $correct, true );
00085 
00086         // Verify resutls available when partial page name is entered as the search text
00087         $this->type( SeleniumTestConstants::INPUT_SEARCH_BOX, "Calcey" );
00088         $this->click( SeleniumTestConstants::BUTTON_SEARCH );
00089         $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
00090 
00091         //  Verify text avaialble in the search result under the page titles
00092         if($this->isElementPresent( "Page_title_matches" )) {
00093             $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" );
00094             $this->assertContains( 'Calcey', $textPageTitle );
00095         }
00096 
00097         //  Verify text avaialble in the search result under the page text
00098         if($this->isElementPresent( "Page_text_matches" )) {
00099             $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" );
00100             $this->assertContains( 'Calcey', $textPageText );
00101         }
00102         $this->deletePage("Calcey QA");
00103         $this->deletePage("Calcey web");
00104     }
00105 }