Repository navigation
Expand file tree
/
Copy pathSeleniumTest.php
More file actions
100 lines (84 loc) · 2.62 KB
/
Copy pathSeleniumTest.php
File metadata and controls
100 lines (84 loc) · 2.62 KB
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
<?php
use Codeception\Util\Stub;
require_once 'tests/data/app/data.php';
require_once __DIR__ . '/TestsForMink.php';
class SeleniumTest extends TestsForMink
{
/**
* @var \Codeception\Module\Selenium
*/
protected $module;
// this is my local config
protected $is_local = false;
public function setUp()
{
$this->noPhpWebserver();
$this->noSelenium();
$this->module = new \Codeception\Module\Selenium();
$url = '';
if (version_compare(PHP_VERSION, '5.4', '>=')) {
$url = 'http://localhost:8000';
}
// my local config.
if ($this->is_local) {
$url = 'http://testapp.com';
}
$this->module->_setConfig(array('url' => $url, 'browser' => 'firefox'));
// $this->markTestSkipped('lets test selenium2 instead');
$this->module->_initialize();
$this->module->_cleanup();
$this->module->_before($this->makeTest());
$this->markTestSkipped('Selenium RC tests should be disabled and deprecated');
}
public function tearDown()
{
$this->noPhpWebserver();
$this->noSelenium();
$this->module->_after($this->makeTest());
data::clean();
}
protected function makeTest()
{
return Stub::makeEmpty(
'\Codeception\TestCase\Cept',
array('dispatcher' => Stub::makeEmpty('Symfony\Component\EventDispatcher\EventDispatcher'))
);
}
protected function noSelenium()
{
$fp = @fsockopen('localhost', 4444);
if ($fp !== false) {
fclose($fp);
return true;
}
$this->markTestSkipped(
'Requires Selenium Server running'
);
return false;
}
protected function noPhpWebserver()
{
if (version_compare(PHP_VERSION, '5.4', '<') and (! $this->is_local)) {
$this->markTestSkipped('Requires PHP built-in web server, available only in PHP 5.4.');
}
}
public function testSelectByLabel()
{
// In Selenium you can't select option by it's value
}
public function testClickEventOnCheckbox()
{
$this->module->amOnPage('/form/checkbox');
$this->module->uncheckOption('#checkin');
$this->module->dontSee('ticked','#notice');
$this->module->checkOption('#checkin');
$this->module->see('ticked','#notice');
}
public function testRawSelenium()
{
$this->module->executeInSelenium(function (\Selenium\Browser $browser) {
$browser->open('/info');
});
$this->module->seeCurrentUrlEquals('/info');
}
}