WebDriver.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. // Copyright 2004-present Facebook. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. namespace Facebook\WebDriver;
  16. use Facebook\WebDriver\Interactions\Touch\WebDriverTouchScreen;
  17. /**
  18. * The interface for WebDriver.
  19. */
  20. interface WebDriver extends WebDriverSearchContext
  21. {
  22. /**
  23. * Close the current window.
  24. *
  25. * @return WebDriver The current instance.
  26. */
  27. public function close();
  28. /**
  29. * Load a new web page in the current browser window.
  30. *
  31. * @param string $url
  32. * @return WebDriver The current instance.
  33. */
  34. public function get($url);
  35. /**
  36. * Get a string representing the current URL that the browser is looking at.
  37. *
  38. * @return string The current URL.
  39. */
  40. public function getCurrentURL();
  41. /**
  42. * Get the source of the last loaded page.
  43. *
  44. * @return string The current page source.
  45. */
  46. public function getPageSource();
  47. /**
  48. * Get the title of the current page.
  49. *
  50. * @return string The title of the current page.
  51. */
  52. public function getTitle();
  53. /**
  54. * Return an opaque handle to this window that uniquely identifies it within
  55. * this driver instance.
  56. *
  57. * @return string The current window handle.
  58. */
  59. public function getWindowHandle();
  60. /**
  61. * Get all window handles available to the current session.
  62. *
  63. * @return array An array of string containing all available window handles.
  64. */
  65. public function getWindowHandles();
  66. /**
  67. * Quits this driver, closing every associated window.
  68. */
  69. public function quit();
  70. /**
  71. * Take a screenshot of the current page.
  72. *
  73. * @param string $save_as The path of the screenshot to be saved.
  74. * @return string The screenshot in PNG format.
  75. */
  76. public function takeScreenshot($save_as = null);
  77. /**
  78. * Construct a new WebDriverWait by the current WebDriver instance.
  79. * Sample usage:
  80. *
  81. * $driver->wait(20, 1000)->until(
  82. * WebDriverExpectedCondition::titleIs('WebDriver Page')
  83. * );
  84. *
  85. * @param int $timeout_in_second
  86. * @param int $interval_in_millisecond
  87. * @return WebDriverWait
  88. */
  89. public function wait(
  90. $timeout_in_second = 30,
  91. $interval_in_millisecond = 250
  92. );
  93. /**
  94. * An abstraction for managing stuff you would do in a browser menu. For
  95. * example, adding and deleting cookies.
  96. *
  97. * @return WebDriverOptions
  98. */
  99. public function manage();
  100. /**
  101. * An abstraction allowing the driver to access the browser's history and to
  102. * navigate to a given URL.
  103. *
  104. * @return WebDriverNavigation
  105. * @see WebDriverNavigation
  106. */
  107. public function navigate();
  108. /**
  109. * Switch to a different window or frame.
  110. *
  111. * @return WebDriverTargetLocator
  112. * @see WebDriverTargetLocator
  113. */
  114. public function switchTo();
  115. /**
  116. * @return WebDriverTouchScreen
  117. * @todo Add in next major release (BC)
  118. */
  119. //public function getTouch();
  120. /**
  121. * @param string $name
  122. * @param array $params
  123. * @return mixed
  124. */
  125. public function execute($name, $params);
  126. }