From cf154bdcdcb0dd546b11b1c49fc015d310e34780 Mon Sep 17 00:00:00 2001 From: nadeesha Date: Thu, 2 Dec 2010 04:21:29 +0000 Subject: [PATCH] Test file deleted from Calcey --- .../suites/AddContentToNewPageTestCase.php | 258 ++++++++++++++++++ .../selenium/suites/AddNewPageTestCase.php | 61 +++++ .../suites/DeletePageAdminTestCase.php | 68 +++++ .../selenium/suites/MediaWikiCommonFunc.php | 77 ++++++ .../selenium/suites/MediaWikiEditorConfig.php | 16 ++ .../suites/MediaWikiEditorTestSuite.php | 30 ++ .../selenium/suites/PageSearchTestCase.php | 123 +++++++++ maintenance/tests/selenium/suites/calcey.txt | 0 8 files changed, 633 insertions(+) create mode 100644 maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php create mode 100644 maintenance/tests/selenium/suites/AddNewPageTestCase.php create mode 100644 maintenance/tests/selenium/suites/DeletePageAdminTestCase.php create mode 100644 maintenance/tests/selenium/suites/MediaWikiCommonFunc.php create mode 100644 maintenance/tests/selenium/suites/MediaWikiEditorConfig.php create mode 100644 maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php create mode 100644 maintenance/tests/selenium/suites/PageSearchTestCase.php delete mode 100644 maintenance/tests/selenium/suites/calcey.txt diff --git a/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php new file mode 100644 index 0000000000..be9253aae3 --- /dev/null +++ b/maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php @@ -0,0 +1,258 @@ +getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-bold']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + try{ + $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/b")); + $blnElementPresent = True; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnElementPresent = False; + } + + try{ + $this->assertTrue($this->isTextPresent( "Bold text" )); + $blnTextPresent = True; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnTextPresent = False; + } + + // Verify bold text displayed on mediawiki preview + if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){ + echo "\n Pass : Bold text displayed in the preview \n"; + } + else{ + echo "\n Fail : Bold text displayed in the preview \n"; + } + } + + // Add italic text and verify output + public function testAddItalicText(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-italic']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify italic text displayed on mediawiki preview + try{ + $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/p/i")); + $blnElementPresent = True; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnElementPresent = False; + } + + try{ + $this->assertTrue($this->isTextPresent( "Italic text" )); + $blnTextPresent = True; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnTextPresent = False; + } + + // Verify italic text displayed on mediawiki preview + if (( $blnElementPresent = True ) && ( $blnTextPresent = True )){ + echo "\n Pass : Italic text displayed in the preview \n"; + } + else{ + echo "\n Fail : Italic text displayed in the preview \n"; + } + + } + + // Add internal link for a new page and verify output in the preview + public function testAddInternalLinkNewPage(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-link']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify internal link displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $correct = strstr( $source, "Link title" ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Internal link displayed in the preview \n"; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Pass : Internal link displayed in the preview \n"; + } + + $this->click( "link=Link title" ); + $this->waitForPageToLoad( "600000" ); + + // Verify internal link open as a new page - editing mode + $source = $this->getText( "firstHeading" ); + $correct = strstr( $source, "Editing Link title" ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Internal link opened as a new page in the editing mode \n"; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : Internal link opened as a new page in the editing mode \n"; + } + } + + // Add external link and verify output in the preview + public function testAddExternalLink(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-extlink']" ); + $this->type( "wpTextbox1", "[http://www.google.com Google]" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify external links displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $correct = strstr( $source, "Google" ); + + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : External link displayed in the preview \n"; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : External link displayed in thw preview \n"; + } + + $this->click( "link=Google" ); + $this->waitForPageToLoad( "600000" ); + + // Verify external link opens + $source = $this->getTitle(); + $correct = strstr( $source, "Google" ); + try{ + $this->assertEquals( $correct, true); + echo "\n Pass : External link opened \n"; + + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : External link opened \n"; + } + + } + + // Add level 2 headline and verify output in the preview + public function testAddLevel2HeadLine(){ + $blnElementPresent = False; + $blnTextPresent = False; + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-headline" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + try { + $this->assertTrue($this->isElementPresent("//div[@id='wikiPreview']/h2")); + $blnElementPresent = True; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnElementPresent = False; + } + + try{ + $source = $this->getText( "//*[@id='Headline_text']" ); + $correct = strstr( $source, "Headline text" ); + $this->assertEquals( $correct, true ); + $blnTextPresent = True; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + $blnTextPresent = False; + } + + if(($blnElementPresent = True) && ($blnTextPresent = True)){ + echo "\n Pass : Headline text displayed in the preview \n"; + } + else{ + echo "\n Fail : Headline text displayed in the preview \n"; + } + } + + // Add text with ignore wiki format and verify output the preview + public function testAddNoWikiFormat(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "//*[@id='mw-editbutton-nowiki']" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify ignore wiki format text displayed on mediawiki preview + $source = $this->getText( "//div[@id='wikiPreview']/p" ); + $correct = strstr( $source, "Insert non-formatted text here" ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Text available without wiki formats in the preview \n "; + + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : Text available without wiki formats in the preview\n "; + } + } + + // Add signature and verify output in the preview + public function testAddUserSignature(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-signature" ); + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify signature displayed on mediawiki preview + $source = $this->getText( "//*[@id='wikiPreview']/p/a" ); + $username = $this->getText( "//*[@id='pt-userpage']/a" ); + $correct = strstr( $source, $username ); + + try{ + $this->assertEquals( $correct, true); + echo "\n Pass : Correct name displayed in the preview \n "; + + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : Correct name displayed in the preview \n "; + } + } + + // Add horizontal line and verify output in the preview + public function testHorizontalLine(){ + $this->getExistingPage(); + $this->clickEditLink(); + $this->loadWikiEditor(); + $this->clearWikiEditor(); + $this->click( "mw-editbutton-hr" ); + + $this->clickShowPreviewBtn(); + $this->waitForPageToLoad( "600000" ); + + // Verify horizontal line displayed on mediawiki preview + try{ + $this->assertTrue( $this->isElementPresent( "//div[@id='wikiPreview']/hr" )); + echo "\n Pass: Horizontal line displayed in the preview \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : Horizontal line displayed in the preview \n "; + } + } + + + } diff --git a/maintenance/tests/selenium/suites/AddNewPageTestCase.php b/maintenance/tests/selenium/suites/AddNewPageTestCase.php new file mode 100644 index 0000000000..6b03c45c3c --- /dev/null +++ b/maintenance/tests/selenium/suites/AddNewPageTestCase.php @@ -0,0 +1,61 @@ +open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type("searchInput", "new"); + $this->click("searchGoButton"); + $this->waitForPageToLoad("600000"); + + // Verify 'Search results' text available + $source = $this->gettext( "firstHeading" ); + $correct = strstr( $source, "Search results"); + try{ + $this->assertEquals( $correct, true); + echo "\n Pass : Text'Search results' displayed \n"; + + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : Text' Search results' displayed \n" ; + } + + // Verify 'Create the page "" on this wiki' text available + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr ( $source, "Create the page \"New\" on this wiki!" ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Text 'Create the page \"New\" on this wiki!' displayed \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : Text 'Create the page \"New\" on this wiki!' displayed \n"; + } + + $this->click("link=New"); + $this->waitForPageToLoad("600000"); + + // Verify 'Create' tab available + try{ + $this->assertTrue($this->isElementPresent("link=Create")); + echo "\n Pass : 'Create' tab displayed \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e) { + echo "\n Fail : 'Create' tab displayed \n"; + } + + $this->type("wpTextbox1", "add new test page"); + $this->click("wpSave"); + + // Verify new page added + $source = $this->gettext( "firstHeading" ); + $correct = strstr ( $source, "New" ); + try{ + $this->assertEquals( $correct, true); + echo "\n Pass : New page added \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : New page added \n"; + } + } +} diff --git a/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php b/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php new file mode 100644 index 0000000000..c701db9764 --- /dev/null +++ b/maintenance/tests/selenium/suites/DeletePageAdminTestCase.php @@ -0,0 +1,68 @@ +open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click("link=Log out"); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "wpName1", "nadeesha" ); + $this->type( "wpPassword1", "12345" ); + $this->click( "wpLoginAttempt" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "searchInput", "new" ); + $this->click( "searchGoButton"); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Delete' link displayed + $source = $this->gettext( "link=Delete" ); + $correct = strstr ( $source, "Delete" ); + try{ + $this->assertEquals( $correct, true); + echo "\n Pass : 'Delete' link displayed \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Fail : 'Delete' link displayed \n"; + } + $this->click( "link=Delete" ); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Delete' button available + $this->assertTrue($this->isElementPresent( "wpConfirmB" )); + + try{ + $this->assertTrue($this->isElementPresent( "wpConfirmB" )); + echo "\n Pass : 'Delete' button available \n"; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : 'Delete' button available \n"; + } + $this->click( "wpConfirmB" ); + $this->waitForPageToLoad( "30000" ); + + // Verify 'Action complete' text displayed + $source = $this->gettext( "firstHeading" ); + $correct = strstr ( $source, "Action complete" ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : 'Action complete' text displayed \n"; + }catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : 'Action complete' text displayed \n"; + } + + // Verify ' has been deleted. See deletion log for a record of recent deletions.' text displayed + $source = $this->gettext( "//div[@id='bodyContent']/p[1]" ); + $correct = strstr ( $source, "\"New\" has been deleted. See deletion log for a record of recent deletions." ); + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Page deleted successfully \n"; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : Page deleted successfully \n"; + } + } +} diff --git a/maintenance/tests/selenium/suites/MediaWikiCommonFunc.php b/maintenance/tests/selenium/suites/MediaWikiCommonFunc.php new file mode 100644 index 0000000000..0dee22e1c0 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikiCommonFunc.php @@ -0,0 +1,77 @@ +open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type("searchInput", "new" ); + $this->click("searchGoButton"); + $this->waitForPageToLoad("30000"); + } + + // Creating new page + public function getNewPage($pageName){ + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type("searchInput", $pageName ); + $this->click("searchGoButton"); + $this->waitForPageToLoad("30000"); + $this->click("link=".$pageName); + $this->waitForPageToLoad("600000"); + } + + // Deleting the given page + public function deletePage($pageName){ + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->click("link=Log out"); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=Log in / create account" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "wpName1", "nadeesha" ); + $this->type( "wpPassword1", "12345" ); + $this->click( "wpLoginAttempt" ); + $this->waitForPageToLoad( "30000" ); + $this->type( "searchInput", $pageName ); + $this->click( "searchGoButton"); + $this->waitForPageToLoad( "30000" ); + $this->click( "link=Delete" ); + $this->waitForPageToLoad( "30000" ); + $this->click( "wpConfirmB" ); + $this->waitForPageToLoad( "30000" ); + } + + // Loading the mediawiki editor + public function loadWikiEditor(){ + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + } + + // Clear the content of the mediawiki editor + public function clearWikiEditor(){ + $this->type("wpTextbox1", ""); + } + + // Click on the 'Show preview' button of the mediawiki editor + public function clickShowPreviewBtn(){ + $this->click("wpPreview"); + } + + // Click on the 'Save Page' button of the mediawiki editor + public function clickSavePageBtn(){ + $this->click("wpSave"); + } + + // Click on the 'Edit' link + public function clickEditLink(){ + $this->click("link=Edit"); + $this->waitForPageToLoad("30000"); + } + + + +} diff --git a/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php new file mode 100644 index 0000000000..a2b53f45ec --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikiEditorConfig.php @@ -0,0 +1,16 @@ + 'chick' + ); + $includeFiles = array_merge( $includeFiles, $includes ); + $globalConfigs = array_merge( $globalConfigs, $configs); + return true; + } +} \ No newline at end of file diff --git a/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php b/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php new file mode 100644 index 0000000000..0e5caf38b9 --- /dev/null +++ b/maintenance/tests/selenium/suites/MediaWikiEditorTestSuite.php @@ -0,0 +1,30 @@ +setLoginBeforeTests( True ); + parent::setUp(); + } + public function addTests() { + $testFiles = array( + 'maintenance/tests/selenium/suites/AddNewPageTestCase.php', + 'maintenance/tests/selenium/suites/AddContentToNewPageTestCase.php', + 'maintenance/tests/selenium/suites/DeletePageAdminTestCase.php', + 'maintenance/tests/selenium/suites/PageSearchTestCase.php' + + ); + parent::addTestFiles( $testFiles ); + } + + +} diff --git a/maintenance/tests/selenium/suites/PageSearchTestCase.php b/maintenance/tests/selenium/suites/PageSearchTestCase.php new file mode 100644 index 0000000000..46ccce1191 --- /dev/null +++ b/maintenance/tests/selenium/suites/PageSearchTestCase.php @@ -0,0 +1,123 @@ +open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", "calcey qa" ); + $this->click( "searchGoButton" ); + $this->waitForPageToLoad( "600000" ); + + // Verify no page matched with the entered search text + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr ( $source, "Create the page \"Calcey qa\" on this wiki!" ); + + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : No page matched with the entered search text using the 'Go' button \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Pass : No page matched with the entered search text using the 'Go' button \n"; + } + + $this->click( "link=Calcey qa" ); + $this->waitForPageToLoad( "600000" ); + + $this->type( "wpTextbox1", "Calcey QA team" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "600000" ); + + } + + // Verify the functionality of the 'Search' button + public function testPageSearchBtnSearch(){ + + $this->open( $this->getUrl() . + '/index.php?title=Main_Page&action=edit' ); + $this->type( "searchInput", "Calcey web" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify no page is available as the search text + $source = $this->gettext( "//div[@id='bodyContent']/div[4]/p[2]/b" ); + $correct = strstr ( $source, "Create the page \"Calcey web\" on this wiki!" ); + + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : No page matched with the entered search text using the 'Search' button \n"; + } catch (PHPUnit_Framework_AssertionFailedError $e){ + echo "\n Pass : No page matched with the entered search text using the 'Search' button \n"; + } + + $this->click( "link=Calcey web" ); + $this->waitForPageToLoad( "600000" ); + + $this->type( "wpTextbox1", "Calcey web team" ); + $this->click( "wpSave" ); + $this->waitForPageToLoad( "600000" ); + + + // Verify saved page is opened when the exact page name is given + $this->type( "searchInput", "Calcey web" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + $source = $this->getText( "//*[@id='bodyContent']/div[4]/p/b" ); + $correct = strstr( $source, "There is a page named \"Calcey web\" on this wiki." ); + + try{ + $this->assertEquals( $correct, true ); + echo "\n Pass : Exact page matched with the entered search text using 'Search' button \n"; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : Exact page matched with the entered search text using 'Search' button \n"; + } + + + // Verify resutls available when partial page name is entered as the search text + + $this->type( "searchInput", "Calcey" ); + $this->click( "mw-searchButton" ); + $this->waitForPageToLoad( "30000" ); + + // Verify text avaialble in the search result under the page titles + if($this->isElementPresent( "Page_title_matches" )){ + try{ + $textPageTitle = $this->getText( "//*[@id='bodyContent']/div[4]/ul[1]/li[1]/div[1]/a" ); + $this->assertContains( 'Calcey', $textPageTitle ); + echo "\n Pass : Results displayed under 'Page title matches' heading for the partial title match match using the 'Search' button\n"; + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : Results displayed under 'Page title matches' heading for the partial title match match using the 'Search' button \n"; + } + } + else{ + echo "\n Pass : No results avaialble for the 'Page title matches' heading for the partial title match using the 'Search' button \n"; + } + + // Verify text avaialble in the search result under the page text + if($this->isElementPresent( "Page_text_matches" )){ + try{ + $textPageText = $this->getText( "//*[@id='bodyContent']/div[4]/ul[2]/li[2]/div[2]/span" ); + $this->assertContains( 'Calcey', $textPageText ); + + echo "\n Pass : Results displayed under 'Page text matches' heading for the partial text match using the 'Search' button \n"; + + } catch ( PHPUnit_Framework_AssertionFailedError $e ){ + echo "\n Fail : Results displayed under 'Page text matches' heading for the partial text match using the 'Search' button \n"; + } + } + else{ + echo "\n Pass : No results avaialble for the 'Page text matches' heading for the partial title match using the 'Search' button\n"; + } + $this->deletePage("Calcey QA"); + $this->deletePage("Calcey web"); + + } + + + +} diff --git a/maintenance/tests/selenium/suites/calcey.txt b/maintenance/tests/selenium/suites/calcey.txt deleted file mode 100644 index e69de29bb2..0000000000 -- 2.20.1