|
37 | 37 | * @method mixed execute($jsonScript) Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (synchronous) |
38 | 38 | * @method mixed execute_async($jsonScript) Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame. (asynchronous) |
39 | 39 | * @method string screenshot() Take a screenshot of the current page. |
40 | | - * @method void frame($jsonFrameId) Change focus to another frame on the page. |
41 | 40 | * @method array getCookie() Retrieve all cookies visible to the current page. |
42 | 41 | * @method array postCookie($jsonCookie) Set a cookie. |
43 | 42 | * @method string source() Get the current page source. |
@@ -82,7 +81,6 @@ protected function methods() |
82 | 81 | 'execute' => array('POST'), |
83 | 82 | 'execute_async' => array('POST'), |
84 | 83 | 'screenshot' => array('GET'), |
85 | | - 'frame' => array('POST'), |
86 | 84 | 'cookie' => array('GET', 'POST'), // for DELETE, use deleteAllCookies() |
87 | 85 | 'source' => array('GET'), |
88 | 86 | 'title' => array('GET'), |
@@ -277,12 +275,32 @@ public function focusWindow($name) |
277 | 275 | return $this; |
278 | 276 | } |
279 | 277 |
|
| 278 | + /** |
| 279 | + * frame methods: /session/:sessionId/frame (POST) |
| 280 | + * - $session->frame($json) - change focus to another frame on the page |
| 281 | + * - $session->frame()->method() - chaining |
| 282 | + * |
| 283 | + * @return \WebDriver\Session|\WebDriver\Frame |
| 284 | + */ |
| 285 | + public function frame() |
| 286 | + { |
| 287 | + if (func_num_args() === 1) { |
| 288 | + $arg = func_get_arg(0); // json |
| 289 | + $this->curl('POST', '/frame', $arg); |
| 290 | + |
| 291 | + return $this; |
| 292 | + } |
| 293 | + |
| 294 | + // chaining |
| 295 | + return new Frame($this->url . '/frame'); |
| 296 | + } |
| 297 | + |
280 | 298 | /** |
281 | 299 | * timeouts methods: /session/:sessionId/timeouts (POST) |
282 | 300 | * - $session->timeouts($json) - set timeout for an operation |
283 | 301 | * - $session->timeouts()->method() - chaining |
284 | 302 | * |
285 | | - * @return \WebDriver\Timeouts |
| 303 | + * @return \WebDriver\Session|\WebDriver\Timeouts |
286 | 304 | */ |
287 | 305 | public function timeouts() |
288 | 306 | { |
|
0 commit comments