1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Webino (http://webino.sk/) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/webino/WebinoDev/ for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2016 Webino, s. r. o. (http://webino.sk/) |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace WebinoDev\Test\Selenium\WebDriver; |
11
|
|
|
use PHPWebDriver_Support_WebDriverSelect; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* For mocking PHPWebDriver_WebDriverSimpleItem |
15
|
|
|
*/ |
16
|
|
|
class Select |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var PHPWebDriver_Support_WebDriverSelect |
20
|
|
|
*/ |
21
|
|
|
protected $select; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param \PHPWebDriver_WebDriverElement $elm |
25
|
|
|
* @param PHPWebDriver_Support_WebDriverSelect|null $select |
26
|
|
|
*/ |
27
|
|
|
public function __construct($elm, PHPWebDriver_Support_WebDriverSelect $select = null) |
28
|
|
|
{ |
29
|
|
|
$this->select = $select ? $select : new PHPWebDriver_Support_WebDriverSelect($elm); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return array |
34
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
35
|
|
|
*/ |
36
|
|
|
public function getOptions() |
37
|
|
|
{ |
38
|
|
|
return $this->select->__get('options'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return array |
43
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
44
|
|
|
*/ |
45
|
|
|
public function getSelectedOptions() |
46
|
|
|
{ |
47
|
|
|
return $this->select->__get('all_selected_options'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return array |
52
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
53
|
|
|
*/ |
54
|
|
|
public function getFirstSelectedValue() |
55
|
|
|
{ |
56
|
|
|
return $this->select->__get('first_selected_value'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return array |
61
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
62
|
|
|
*/ |
63
|
|
|
public function isMultiple() |
64
|
|
|
{ |
65
|
|
|
return $this->select->__get('is_multiple'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $value |
70
|
|
|
* @return $this |
71
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
72
|
|
|
*/ |
73
|
|
|
public function selectByValue($value) |
74
|
|
|
{ |
75
|
|
|
$this->select->select_by_value($value); |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param int $index |
81
|
|
|
* @return $this |
82
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
83
|
|
|
*/ |
84
|
|
|
public function selectByIndex($index) |
85
|
|
|
{ |
86
|
|
|
$this->select->select_by_index($index); |
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param string $text |
92
|
|
|
* @return $this |
93
|
|
|
* @throws \PHPWebDriver_NoSuchElementWebDriverError |
94
|
|
|
*/ |
95
|
|
|
public function selectByText($text) |
96
|
|
|
{ |
97
|
|
|
$this->select->select_by_visible_text($text); |
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return $this |
103
|
|
|
* @throws \PHPWebDriver_NotImplementedError |
104
|
|
|
*/ |
105
|
|
|
public function deselectAll() |
106
|
|
|
{ |
107
|
|
|
$this->select->deselect_all(); |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param string $value |
113
|
|
|
* @return $this |
114
|
|
|
* @throws \PHPWebDriver_NotImplementedError |
115
|
|
|
*/ |
116
|
|
|
public function deselectByValue($value) |
117
|
|
|
{ |
118
|
|
|
$this->select->deselect_by_value($value); |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param int $index |
124
|
|
|
* @return $this |
125
|
|
|
* @throws \PHPWebDriver_NotImplementedError |
126
|
|
|
*/ |
127
|
|
|
public function deselectByIndex($index) |
128
|
|
|
{ |
129
|
|
|
$this->select->deselect_by_index($index); |
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param string $text |
135
|
|
|
* @return $this |
136
|
|
|
* @throws \PHPWebDriver_NotImplementedError |
137
|
|
|
*/ |
138
|
|
|
public function deselectByText($text) |
139
|
|
|
{ |
140
|
|
|
$this->select->deselect_by_visible_text($text); |
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|