1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SP\Spiderling; |
4
|
|
|
|
5
|
|
|
use Countable; |
6
|
|
|
use SP\Spiderling\Query; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @author Ivan Kerin <[email protected]> |
10
|
|
|
* @copyright 2015, Clippings Ltd. |
11
|
|
|
* @license http://spdx.org/licenses/BSD-3-Clause |
12
|
|
|
*/ |
13
|
|
|
class BrowserSession extends Session |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var BrowserInterface |
17
|
|
|
*/ |
18
|
|
|
private $browser; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param BrowserInterface $browser |
22
|
|
|
*/ |
23
|
1 |
|
public function __construct(BrowserInterface $browser) { |
24
|
|
|
|
25
|
1 |
|
$this->browser = $browser; |
26
|
|
|
|
27
|
1 |
|
parent::__construct($browser); |
28
|
1 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @return BrowserInterface |
32
|
|
|
*/ |
33
|
1 |
|
public function getBrowser() |
34
|
|
|
{ |
35
|
1 |
|
return $this->browser; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
1 |
|
public function getAlertText() |
42
|
|
|
{ |
43
|
1 |
|
return $this->browser->getAlertText(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param string $confirm |
48
|
|
|
*/ |
49
|
1 |
|
public function confirm($confirm) |
50
|
|
|
{ |
51
|
1 |
|
$this->browser->confirm($confirm); |
52
|
|
|
|
53
|
1 |
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $name |
58
|
|
|
* @param string $value |
59
|
|
|
* @param integer $expires |
60
|
|
|
* @return self |
61
|
|
|
*/ |
62
|
|
|
public function setCookie($name, $value = '', $expires = 0) |
63
|
|
|
{ |
64
|
|
|
$this->browser->setCookie($name, $value, $expires); |
|
|
|
|
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param string $name |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getCookie($name) |
74
|
|
|
{ |
75
|
|
|
return $this->browser->getCookie($name); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param string $name |
80
|
|
|
* @return self |
81
|
|
|
*/ |
82
|
|
|
public function removeCookie($name) |
83
|
|
|
{ |
84
|
|
|
$this->browser->removeCookie($name); |
|
|
|
|
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return self |
91
|
|
|
*/ |
92
|
1 |
|
public function removeAllCookies() |
93
|
|
|
{ |
94
|
1 |
|
$this->browser->removeAllCookies(); |
95
|
|
|
|
96
|
1 |
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param string $javascript |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
1 |
|
public function executeJs($javascript) |
104
|
|
|
{ |
105
|
1 |
|
return $this->browser->executeJs($javascript); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return array |
110
|
|
|
*/ |
111
|
1 |
|
public function getJsErrors() |
112
|
|
|
{ |
113
|
1 |
|
return $this->browser->getJsErrors(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return array |
118
|
|
|
*/ |
119
|
1 |
|
public function getJsMessages() |
120
|
|
|
{ |
121
|
1 |
|
return $this->browser->getJsMessages(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param string $file |
126
|
|
|
* @return self |
127
|
|
|
*/ |
128
|
1 |
|
public function saveScreenshot($file) |
129
|
|
|
{ |
130
|
1 |
|
$this->browser->saveScreenshot($file); |
131
|
|
|
|
132
|
1 |
|
return $this; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param Node $node |
137
|
|
|
* @return self |
138
|
|
|
*/ |
139
|
1 |
|
public function hoverNode(Node $node) |
140
|
|
|
{ |
141
|
1 |
|
$this->browser->moveMouseTo($node->getId()); |
142
|
|
|
|
143
|
1 |
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @param string $selector |
148
|
|
|
* @return self |
149
|
|
|
*/ |
150
|
1 |
|
public function hover($selector) |
151
|
|
|
{ |
152
|
1 |
|
$this->hoverNode($this->get($selector)); |
153
|
|
|
|
154
|
1 |
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param string $selector |
159
|
|
|
* @return self |
160
|
|
|
*/ |
161
|
1 |
|
public function hoverButton($selector) |
162
|
|
|
{ |
163
|
1 |
|
$this->hoverNode($this->getButton($selector)); |
164
|
|
|
|
165
|
1 |
|
return $this; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param string $selector |
170
|
|
|
* @return self |
171
|
|
|
*/ |
172
|
1 |
|
public function hoverField($selector) |
173
|
|
|
{ |
174
|
1 |
|
$this->hoverNode($this->getField($selector)); |
175
|
|
|
|
176
|
1 |
|
return $this; |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.