Skip to content

Commit 9cf297c

Browse files
committed
Merge pull request #35 from javigomez/multiselect
Add select multiple options in chosen
2 parents 359e48f + 7a50a8a commit 9cf297c

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ In between the available functions you can find:
3333
* do frontend login
3434
* ADMINISTRATOR USER INTERFACE:
3535
* select option in chosen
36-
* selectOptionInRadioField
36+
* select Option In Radio Field
37+
* select Multiple Options In Chosen
3738
* OTHERS:
3839
* check for php notices or warnings
3940

src/JoomlaBrowser.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,30 @@ public function selectOptionInChosen($label, $option)
345345
$I->wait(1); // Gives time to chosen to close
346346
}
347347

348+
/**
349+
* Selects one or more options in a Chosen Multiple Select based on its label
350+
*
351+
* @param string $label Label of the select field
352+
* @param array $options Array of options to be selected
353+
*
354+
* @return void
355+
*/
356+
public function selectMultipleOptionsInChosen($label, $options)
357+
{
358+
$select = $this->findField($label);
359+
$selectID = $select->getAttribute('id');
360+
$chosenSelectID = $selectID . '_chzn';
361+
$I = $this;
362+
foreach ($options as $option)
363+
{
364+
$this->debug("I open the $label chosen selector");
365+
$I->click(['xpath' => "//div[@id='$chosenSelectID']/ul"]);
366+
$this->debug("I select $option");
367+
$I->click(['xpath' => "//div[@id='$chosenSelectID']//li[contains(text()[normalize-space()], '$option')]"]);
368+
$I->wait(1); // Gives time to chosen to close
369+
}
370+
}
371+
348372
/**
349373
* Function to Logout from Administrator Panel in Joomla!
350374
*

0 commit comments

Comments
 (0)