Last active
September 13, 2018 12:24
-
-
Save steffenr/c3e79cc0d4dec8defe5cee7406274087 to your computer and use it in GitHub Desktop.
Revisions
-
steffenr renamed this gist
Sep 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
steffenr created this gist
Sep 12, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php /** * @When /^(?:|I )fill in select2 input "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and select "(?P<entry>(?:[^"]|\\")*)"$/ */ public function iFillInSelectInputWithAndSelect($field, $value, $entry) { $page = $this->getSession()->getPage(); $inputField = $page->find('css', $field); if (!$inputField) { throw new \Exception('No field found'); } $choice = $inputField->getParent()->find('css', '.select2-selection'); if (!$choice) { throw new \Exception('No select2 choice found'); } $choice->press(); $select2Input = $page->find('css', '.select2-search__field'); if (!$select2Input) { throw new \Exception('No input found'); } $select2Input->setValue($value); $this->getSession()->wait(1000); $chosenResults = $page->findAll('css', '.select2-results li'); foreach ($chosenResults as $result) { if ($result->getText() == $entry) { $result->click(); break; } } }