-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
63 lines (53 loc) · 1.63 KB
/
search.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
<?php
/**
* @file search.php
*
* Tests the search functionality for menshealth, runnersworld, womenshealthmag
*/
require_once('./vendor/facebook/webdriver/vendor/autoload.php');
class zeusSearch extends \PHPUnit_Framework_TestCase
{
protected $driver;
protected function setUp() {
parent::setUp();
$capabilities = DesiredCapabilities::firefox();
$host = 'http://localhost:4444/wd/hub';
$this->driver = RemoteWebDriver::create($host, $capabilities, 45000);
}
protected function tearDown() {
$this->driver->close();
parent::tearDown();
}
public function testSearch() {
$sites = array(
'menshealth' => array(
'site_url' => 'http://www.menshealth.com',
'burger_link' => 'a#menu-btn-toggle',
),
'runnersworld' => array(
'site_url' => 'http://www.runnersworld.com',
'burger_link' => 'a.menu-icon-link',
),
'womenshealth' => array(
'site_url' => 'http://www.womenshealthmag.com',
'burger_link' => 'a#menu-btn-toggle',
),
);
foreach ($sites as $site) {
$this->driver->get($site['site_url']);
$search_term = 'fitness';
$search_link = $this->driver->findElement(
WebDriverBy::className('search-submit')
);
$search_link->click();
$search_field = $this->driver->findElement(
WebDriverBy::className('search-text')
);
$search_field->sendKeys($search_term)->submit();
$results_stats = $this->driver->findElement(
WebDriverBy::cssSelector('.google-appliance-search-stats .placeholder')
);
$this->assertContains($search_term, $results_stats->getText());
}
}
}