WebDriverCheckboxes.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\WebDriverException;
  17. /**
  18. * Provides helper methods for checkboxes.
  19. */
  20. class WebDriverCheckboxes extends AbstractWebDriverCheckboxOrRadio
  21. {
  22. public function __construct(WebDriverElement $element)
  23. {
  24. parent::__construct($element);
  25. $this->type = $element->getAttribute('type');
  26. if ($this->type !== 'checkbox') {
  27. throw new WebDriverException('The input must be of type "checkbox".');
  28. }
  29. }
  30. public function isMultiple()
  31. {
  32. return true;
  33. }
  34. public function deselectAll()
  35. {
  36. foreach ($this->getRelatedElements() as $checkbox) {
  37. $this->deselectOption($checkbox);
  38. }
  39. }
  40. public function deselectByIndex($index)
  41. {
  42. $this->byIndex($index, false);
  43. }
  44. public function deselectByValue($value)
  45. {
  46. $this->byValue($value, false);
  47. }
  48. public function deselectByVisibleText($text)
  49. {
  50. $this->byVisibleText($text, false, false);
  51. }
  52. public function deselectByVisiblePartialText($text)
  53. {
  54. $this->byVisibleText($text, true, false);
  55. }
  56. }