WebDriverSelectInterface.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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\Exception\NoSuchElementException;
  17. use Facebook\WebDriver\Exception\UnsupportedOperationException;
  18. /**
  19. * Models an element of select type, providing helper methods to select and deselect options.
  20. */
  21. interface WebDriverSelectInterface
  22. {
  23. /**
  24. * @return bool Whether this select element support selecting multiple options.
  25. */
  26. public function isMultiple();
  27. /**
  28. * @return WebDriverElement[] All options belonging to this select tag.
  29. */
  30. public function getOptions();
  31. /**
  32. * @return WebDriverElement[] All selected options belonging to this select tag.
  33. */
  34. public function getAllSelectedOptions();
  35. /**
  36. * @throws NoSuchElementException
  37. *
  38. * @return WebDriverElement The first selected option in this select tag (or the currently selected option in a
  39. * normal select)
  40. */
  41. public function getFirstSelectedOption();
  42. /**
  43. * Select the option at the given index.
  44. *
  45. * @param int $index The index of the option. (0-based)
  46. *
  47. * @throws NoSuchElementException
  48. */
  49. public function selectByIndex($index);
  50. /**
  51. * Select all options that have value attribute matching the argument. That is, when given "foo" this would
  52. * select an option like:
  53. *
  54. * `<option value="foo">Bar</option>`
  55. *
  56. * @param string $value The value to match against.
  57. *
  58. * @throws NoSuchElementException
  59. */
  60. public function selectByValue($value);
  61. /**
  62. * Select all options that display text matching the argument. That is, when given "Bar" this would
  63. * select an option like:
  64. *
  65. * `<option value="foo">Bar</option>`
  66. *
  67. * @param string $text The visible text to match against.
  68. *
  69. * @throws NoSuchElementException
  70. */
  71. public function selectByVisibleText($text);
  72. /**
  73. * Select all options that display text partially matching the argument. That is, when given "Bar" this would
  74. * select an option like:
  75. *
  76. * `<option value="bar">Foo Bar Baz</option>`
  77. *
  78. * @param string $text The visible text to match against.
  79. *
  80. * @throws NoSuchElementException
  81. */
  82. public function selectByVisiblePartialText($text);
  83. /**
  84. * Deselect all options in multiple select tag.
  85. *
  86. * @throws UnsupportedOperationException If the SELECT does not support multiple selections
  87. */
  88. public function deselectAll();
  89. /**
  90. * Deselect the option at the given index.
  91. *
  92. * @param int $index The index of the option. (0-based)
  93. * @throws UnsupportedOperationException If the SELECT does not support multiple selections
  94. */
  95. public function deselectByIndex($index);
  96. /**
  97. * Deselect all options that have value attribute matching the argument. That is, when given "foo" this would
  98. * deselect an option like:
  99. *
  100. * `<option value="foo">Bar</option>`
  101. *
  102. * @param string $value The value to match against.
  103. * @throws UnsupportedOperationException If the SELECT does not support multiple selections
  104. */
  105. public function deselectByValue($value);
  106. /**
  107. * Deselect all options that display text matching the argument. That is, when given "Bar" this would
  108. * deselect an option like:
  109. *
  110. * `<option value="foo">Bar</option>`
  111. *
  112. * @param string $text The visible text to match against.
  113. * @throws UnsupportedOperationException If the SELECT does not support multiple selections
  114. */
  115. public function deselectByVisibleText($text);
  116. /**
  117. * Deselect all options that display text matching the argument. That is, when given "Bar" this would
  118. * deselect an option like:
  119. *
  120. * `<option value="foo">Foo Bar Baz</option>`
  121. *
  122. * @param string $text The visible text to match against.
  123. * @throws UnsupportedOperationException If the SELECT does not support multiple selections
  124. */
  125. public function deselectByVisiblePartialText($text);
  126. }