Guest User

Untitled

a guest
Jan 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public function selectFieldOption($locator, $value)
  2. {
  3. /* @var \Behat\Mink\Element\NodeElement $field */
  4. $field = $this->findField($locator);
  5.  
  6. if (null === $field) {
  7. throw new ElementNotFoundException(
  8. $this->getSession(), 'form field', 'id|name|label|value', $locator
  9. );
  10. }
  11. var_export($locator);
  12. /* @var \Behat\Mink\Selector\SelectorsHandler $handler */
  13. $handler = $this->getSession()->getSelectorsHandler();
  14.  
  15. /*$optionElements = $this->findAll('named', array(
  16. 'option', $handler->selectorToXpath('css', 'option')
  17. ));
  18. */
  19. $optionElements = $this->find('named', array('option', 'red'));
  20. var_dump($optionElements->getValue());
  21. /* @var \Behat\Mink\Element\NodeElement $optionElements */
  22. foreach ($optionElements as $item) {
  23. //var_export($item);
  24. if((string)$item->getText() == $value) {
  25. $actualValue = $item->getValue();
  26. var_export('1');
  27. }
  28. }
  29. $field->selectOption($actualValue);
  30. }
Add Comment
Please, Sign In to add comment