SimplifiedselectElement.php 922 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Mtf\Client\Element;
  7. use Magento\Mtf\Client\Locator;
  8. /**
  9. * Typified element class for option group selectors.
  10. */
  11. class SimplifiedselectElement extends SelectElement
  12. {
  13. /**
  14. * Option group locator.
  15. *
  16. * @var string
  17. */
  18. protected $optionGroupValue = ".//*[@data-title='%s' or contains(normalize-space(.), %s)]";
  19. /**
  20. * Select value in dropdown which has option groups.
  21. *
  22. * @param string $value
  23. * @return void
  24. */
  25. public function setValue($value)
  26. {
  27. $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
  28. $xpath = sprintf($this->optionGroupValue, $value, $this->escapeQuotes($value));
  29. $option = $this->find($xpath, Locator::SELECTOR_XPATH);
  30. $option->click();
  31. }
  32. }