Window.php 2.1 KB

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