1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
class SeleniumTestCase extends PHPUnit_Framework_TestCase { // PHPUnit_Extensions_SeleniumTestCase
protected $selenium;
public function setUp() {
set_time_limit( 60 );
$this->selenium = Selenium::getInstance();
}
public function tearDown() {
}
public function __call( $method, $args ) {
return call_user_func_array( array( $this->selenium, $method ), $args );
}
public function assertSeleniumAttributeEquals( $attribute, $value ) {
$attr = $this->getAttribute( $attribute );
$this->assertEquals( $attr, $value );
}
public function assertSeleniumHTMLContains( $element, $text ) {
$innerHTML = $this->getText( $element );
// or assertContains
$this->assertRegExp( "/$text/", $innerHTML );
}
//Common Funtions Added for Selenium Tests
public function getExistingPage(){
$this->open( $this->getUrl() .
'/index.php?title=Main_Page&action=edit' );
$this->type("searchInput", "new" );
$this->click("searchGoButton");
$this->waitForPageToLoad("30000");
}
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");
}
// 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");
}
public function deletePage($pageName){
$isLinkPresent = False;
$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" );
}
}
|