Skip to content

Commit 969f0f2

Browse files
committed
Merge pull request #86 from javigomez/addselectoptioninchosenbyid
Add selectOptionInChosenByID
2 parents e3c0462 + d6fd529 commit 969f0f2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/JoomlaBrowser.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ public function selectOptionInRadioField($label, $option)
409409
/**
410410
* Selects an option in a Chosen Selector based on its label
411411
*
412+
* @param string $label The text in the <label> with for attribute that links to the <select> element
413+
* @param string $option The text in the <option> to be selected in the chosen selector
414+
*
412415
* @return void
413416
*/
414417
public function selectOptionInChosen($label, $option)
@@ -424,6 +427,25 @@ public function selectOptionInChosen($label, $option)
424427
$I->wait(1); // Gives time to chosen to close
425428
}
426429

430+
/**
431+
* Selects an option in a Chosen Selector based on its label
432+
*
433+
* @param string $selectId The id of the <select> element
434+
* @param string $option The text in the <option> to be selected in the chosen selector
435+
*
436+
* @return void
437+
*/
438+
public function selectOptionInChosenById($selectId, $option)
439+
{
440+
$chosenSelectID = $selectId . '_chzn';
441+
$I = $this;
442+
$this->debug("I open the $chosenSelectID chosen selector");
443+
$I->click(['xpath' => "//div[@id='$chosenSelectID']/a/div/b"]);
444+
$this->debug("I select $option");
445+
$I->click(['xpath' => "//div[@id='$chosenSelectID']//li[text()='$option']"]);
446+
$I->wait(1); // Gives time to chosen to close
447+
}
448+
427449
/**
428450
* Selects one or more options in a Chosen Multiple Select based on its label
429451
*

0 commit comments

Comments
 (0)