-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeleniumRCDemo.php
79 lines (68 loc) · 2.07 KB
/
SeleniumRCDemo.php
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
<?php
require_once 'vendor/autoload.php';
class SeleniumRCDemo extends Sauce\Sausage\SeleniumRCTestCase
{
public static $browsers = array(
// FF 11 on Sauce
array(
'browser' => 'firefox',
'browserVersion' => '11',
'os' => 'Windows 2003'
)//,
//Chrome on Linux on Sauce
//array(
//'browser' => 'googlechrome',
//'browserVersion' => '',
//'os' => 'Linux'
//),
//Chrome on local machine
//array(
//'browser' => 'googlechrome',
//'local' => true
//)
);
public function setUp()
{
$this->setBrowserUrl('http://saucelabs.com/test/guinea-pig');
//$this->setBrowserUrl('http://www.ffbb.com/');
}
public function postSessionSetUp()
{
$this->open('http://saucelabs.com/test/guinea-pig');
}
public function testTitle()
{
$this->assertTitle("I am a page title - Sauce Labs");
}
public function testLink()
{
$this->click('id=i am a link');
$driver = $this;
$title_test = function() use ($driver) {
return ($driver->getTitle() == "I am another page title - Sauce Labs");
};
$this->spinAssert("Title never matched!", $title_test);
}
public function testTextbox()
{
$test_text = "This is some text";
$this->click('id=i_am_a_textbox');
$this->type('id=i_am_a_textbox', $test_text);
$this->assertElementValueEquals('id=i_am_a_textbox', $test_text);
}
public function testSubmitComments()
{
$comment = "This comment rocks lots of rocks";
$this->type('id=comments', $comment);
$this->click('id=submit');
$driver = $this;
$comment_test =
function() use ($comment, $driver)
{
$text = $driver->getText('id=your_comments');
return ($text == "Your comments: $comment");
}
;
$this->spinAssert("Comment never showed up!", $comment_test);
}
}