11e1b192ec3d3896abc2fa62e2cda77c2f354843
[lhc/web/wiklou.git] / maintenance / tests / selenium / SeleniumTestCase.php
1 <?php
2 class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase
3 protected $selenium;
4
5 public function setUp() {
6 set_time_limit( 60 );
7 $this->selenium = Selenium::getInstance();
8 }
9
10 public function tearDown() {
11
12 }
13
14 public function __call( $method, $args ) {
15 return call_user_func_array( array( $this->selenium, $method ), $args );
16 }
17
18 public function assertSeleniumAttributeEquals( $attribute, $value ) {
19 $attr = $this->getAttribute( $attribute );
20 $this->assertEquals( $attr, $value );
21 }
22
23 public function assertSeleniumHTMLContains( $element, $text ) {
24 $innerHTML = $this->getText( $element );
25 // or assertContains
26 $this->assertRegExp( "/$text/", $innerHTML );
27 }
28
29 //Common Funtions Added for Selenium Tests
30
31 public function getExistingPage(){
32 $this->open( $this->getUrl() .
33 '/index.php?title=Main_Page&action=edit' );
34 $this->type("searchInput", "new" );
35 $this->click("searchGoButton");
36 $this->waitForPageToLoad("30000");
37 }
38
39 public function getNewPage($pageName){
40
41 $this->open( $this->getUrl() .
42 '/index.php?title=Main_Page&action=edit' );
43 $this->type("searchInput", $pageName );
44 $this->click("searchGoButton");
45 $this->waitForPageToLoad("30000");
46 $this->click("link=".$pageName);
47 $this->waitForPageToLoad("600000");
48
49
50 }
51 // Loading the mediawiki editor
52 public function loadWikiEditor(){
53 $this->open( $this->getUrl() .
54 '/index.php?title=Main_Page&action=edit' );
55 }
56
57 // Clear the content of the mediawiki editor
58 public function clearWikiEditor(){
59 $this->type("wpTextbox1", "");
60 }
61
62 // Click on the 'Show preview' button of the mediawiki editor
63 public function clickShowPreviewBtn(){
64 $this->click("wpPreview");
65 }
66
67 // Click on the 'Save Page' button of the mediawiki editor
68 public function clickSavePageBtn(){
69 $this->click("wpSave");
70 }
71
72 // Click on the 'Edit' link
73 public function clickEditLink(){
74 $this->click("link=Edit");
75 $this->waitForPageToLoad("30000");
76 }
77
78 public function deletePage($pageName){
79 $isLinkPresent = False;
80 $this->open( $this->getUrl() .
81 '/index.php?title=Main_Page&action=edit' );
82 $this->click("link=Log out");
83 $this->waitForPageToLoad( "30000" );
84 $this->click( "link=Log in / create account" );
85 $this->waitForPageToLoad( "30000" );
86 $this->type( "wpName1", "nadeesha" );
87 $this->type( "wpPassword1", "12345" );
88 $this->click( "wpLoginAttempt" );
89 $this->waitForPageToLoad( "30000" );
90 $this->type( "searchInput", $pageName );
91 $this->click( "searchGoButton");
92 $this->waitForPageToLoad( "30000" );
93
94 $this->click( "link=Delete" );
95 $this->waitForPageToLoad( "30000" );
96 $this->click( "wpConfirmB" );
97 $this->waitForPageToLoad( "30000" );
98
99 }
100
101
102
103 }