Chris@14
|
1 <?php
|
Chris@14
|
2 /**
|
Chris@14
|
3 * Copyright 2011-2017 Anthon Pang. All Rights Reserved.
|
Chris@14
|
4 *
|
Chris@14
|
5 * Licensed under the Apache License, Version 2.0 (the "License");
|
Chris@14
|
6 * you may not use this file except in compliance with the License.
|
Chris@14
|
7 * You may obtain a copy of the License at
|
Chris@14
|
8 *
|
Chris@14
|
9 * http://www.apache.org/licenses/LICENSE-2.0
|
Chris@14
|
10 *
|
Chris@14
|
11 * Unless required by applicable law or agreed to in writing, software
|
Chris@14
|
12 * distributed under the License is distributed on an "AS IS" BASIS,
|
Chris@14
|
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
Chris@14
|
14 * See the License for the specific language governing permissions and
|
Chris@14
|
15 * limitations under the License.
|
Chris@14
|
16 *
|
Chris@14
|
17 * @package WebDriver
|
Chris@14
|
18 *
|
Chris@14
|
19 * @author Anthon Pang <apang@softwaredevelopment.ca>
|
Chris@14
|
20 * @author Fabrizio Branca <mail@fabrizio-branca.de>
|
Chris@14
|
21 */
|
Chris@14
|
22
|
Chris@14
|
23 namespace WebDriver;
|
Chris@14
|
24
|
Chris@14
|
25 /**
|
Chris@14
|
26 * WebDriver\Window class
|
Chris@14
|
27 *
|
Chris@14
|
28 * @package WebDriver
|
Chris@14
|
29 *
|
Chris@14
|
30 * @method array getSize() Get size of the window.
|
Chris@14
|
31 * @method void postSize($json) Change the size of the window.
|
Chris@14
|
32 * @method array getPosition() Get position of the window.
|
Chris@14
|
33 * @method void postPosition($json) Change position of the window.
|
Chris@14
|
34 * @method void maximize() Maximize the window if not already maximized.
|
Chris@14
|
35 */
|
Chris@14
|
36 final class Window extends AbstractWebDriver
|
Chris@14
|
37 {
|
Chris@14
|
38 /**
|
Chris@14
|
39 * Window handle
|
Chris@14
|
40 *
|
Chris@14
|
41 * @var string
|
Chris@14
|
42 */
|
Chris@14
|
43 private $windowHandle;
|
Chris@14
|
44
|
Chris@14
|
45 /**
|
Chris@14
|
46 * {@inheritdoc}
|
Chris@14
|
47 */
|
Chris@14
|
48 protected function methods()
|
Chris@14
|
49 {
|
Chris@14
|
50 return array(
|
Chris@14
|
51 'size' => array('GET', 'POST'),
|
Chris@14
|
52 'position' => array('GET', 'POST'),
|
Chris@14
|
53 'maximize' => array('POST'),
|
Chris@14
|
54 );
|
Chris@14
|
55 }
|
Chris@14
|
56
|
Chris@14
|
57 /**
|
Chris@14
|
58 * {@inheritdoc}
|
Chris@14
|
59 */
|
Chris@14
|
60 protected function obsoleteMethods()
|
Chris@14
|
61 {
|
Chris@14
|
62 return array(
|
Chris@14
|
63 'restore' => array('POST'),
|
Chris@14
|
64 );
|
Chris@14
|
65 }
|
Chris@14
|
66
|
Chris@14
|
67 /**
|
Chris@14
|
68 * Get window handle
|
Chris@14
|
69 *
|
Chris@14
|
70 * @return string
|
Chris@14
|
71 */
|
Chris@14
|
72 public function getHandle()
|
Chris@14
|
73 {
|
Chris@14
|
74 return $this->windowHandle;
|
Chris@14
|
75 }
|
Chris@14
|
76
|
Chris@14
|
77 /**
|
Chris@14
|
78 * Constructor
|
Chris@14
|
79 *
|
Chris@14
|
80 * @param string $url URL
|
Chris@14
|
81 * @param string $windowHandle Window handle
|
Chris@14
|
82 */
|
Chris@14
|
83 public function __construct($url, $windowHandle)
|
Chris@14
|
84 {
|
Chris@14
|
85 $this->windowHandle = $windowHandle;
|
Chris@14
|
86
|
Chris@14
|
87 parent::__construct($url . '/' . $windowHandle);
|
Chris@14
|
88 }
|
Chris@14
|
89 }
|