Last active
August 1, 2017 10:45
-
-
Save fddn/21291efa1800ca548b16429d70d0011c to your computer and use it in GitHub Desktop.
Codeception function to test Select2 dropdown
This file contains hidden or 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 characters
| /** | |
| * Select2Select is for select data from select2 dropdown menu via fill input field | |
| * @param string $id | |
| * @param string $value | |
| */ | |
| public function Select2Select($id, $value) | |
| { | |
| $nonHashmarkId = substr($id, 1); | |
| $this->seeElement($id . ' + .select2'); | |
| $this->executeJS('$("' . $id . ' + .select2 .select2-selection").trigger({type: "mousedown", which: 1})'); | |
| $this->waitForElementVisible('//*[@id="select2-' . $nonHashmarkId . '-results"]', 5); | |
| // SELECT2 Search input field | |
| $this->fillField('body > .select2-container .select2-search__field', $value); | |
| $this->waitForText($value, 5, '//*[@id="select2-' . $nonHashmarkId . '-results"]'); | |
| $this->pressKey('body > .select2-container .select2-search__field', \WebDriverKeys::ENTER); | |
| $this->see($value, $id . ' + .select2-container .select2-selection__rendered'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment