diff --git a/README.md b/README.md index e3f25f6..b02557e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ In between the available functions you can find: * do frontend login * ADMINISTRATOR USER INTERFACE: * select option in chosen - * selectOptionInRadioField + * select Option In Radio Field + * select Multiple Options In Chosen * OTHERS: * check for php notices or warnings diff --git a/src/JoomlaBrowser.php b/src/JoomlaBrowser.php index 9d66b3a..ecdd657 100644 --- a/src/JoomlaBrowser.php +++ b/src/JoomlaBrowser.php @@ -345,6 +345,30 @@ public function selectOptionInChosen($label, $option) $I->wait(1); // Gives time to chosen to close } + /** + * Selects one or more options in a Chosen Multiple Select based on its label + * + * @param string $label Label of the select field + * @param array $options Array of options to be selected + * + * @return void + */ + public function selectMultipleOptionsInChosen($label, $options) + { + $select = $this->findField($label); + $selectID = $select->getAttribute('id'); + $chosenSelectID = $selectID . '_chzn'; + $I = $this; + foreach ($options as $option) + { + $this->debug("I open the $label chosen selector"); + $I->click(['xpath' => "//div[@id='$chosenSelectID']/ul"]); + $this->debug("I select $option"); + $I->click(['xpath' => "//div[@id='$chosenSelectID']//li[contains(text()[normalize-space()], '$option')]"]); + $I->wait(1); // Gives time to chosen to close + } + } + /** * Function to Logout from Administrator Panel in Joomla! *