Skip to content

Commit c7af4c0

Browse files
committed
Merge branch 'release/v3.4.8.2'
2 parents e0f6001 + 8f2f44f commit c7af4c0

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

src/JoomlaBrowser.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public function selectOptionInChosen($label, $option)
429429
}
430430

431431
/**
432-
* Selects an option in a Chosen Selector based on its label
432+
* Selects an option in a Chosen Selector based on its id
433433
*
434434
* @param string $selectId The id of the <select> element
435435
* @param string $option The text in the <option> to be selected in the chosen selector
@@ -447,6 +447,27 @@ public function selectOptionInChosenById($selectId, $option)
447447
$I->wait(1); // Gives time to chosen to close
448448
}
449449

450+
/**
451+
* Selects an option in a Chosen Selector based on its id
452+
*
453+
* @param string $selectId The id of the <select> element
454+
* @param string $option The text in the <option> to be selected in the chosen selector
455+
*
456+
* @return void
457+
*/
458+
public function selectOptionInChosenByIdUsingJs($selectId, $option)
459+
{
460+
$I = $this;
461+
462+
$option = trim($option);
463+
$I->executeJS("jQuery('#$selectId option').filter(function(){ return this.text.trim() === \"$option\" }).prop('selected', true);");
464+
$I->executeJS("jQuery('#$selectId').trigger('liszt:updated').trigger('chosen:updated');");
465+
$I->executeJS("jQuery('#$selectId').trigger('change');");
466+
467+
// give time to Chosen to update
468+
$I->wait(1);
469+
}
470+
450471
/**
451472
* Selects one or more options in a Chosen Multiple Select based on its label
452473
*
@@ -702,6 +723,11 @@ public function clickToolbarButton($button)
702723
$I = $this;
703724
$input = strtolower($button);
704725

726+
$screenSize = explode("x",$this->config['window_size']);
727+
if($screenSize[0] <= 480)
728+
{
729+
$I->click('Toolbar');
730+
}
705731
switch($input)
706732
{
707733
case "new":
@@ -826,16 +852,16 @@ public function setFilter($label, $value)
826852
"select tag" => "filter_tag",
827853
"select max levels" => "filter_level"
828854
);
855+
829856
$I = $this;
830857
$I->click(['xpath' => "//button[@data-original-title='Filter the list items.']"]);
831858
$I->debug('I try to select the filters');
859+
832860
foreach($filters as $fieldName => $id)
833861
{
834862
if($fieldName == $label)
835863
{
836-
$I->waitForElement(['xpath' => "//div[@id='" . $id . "_chzn']/a"], 10);
837-
$I->click(['xpath' => "//div[@id='" . $id . "_chzn']/a"]);
838-
$I->click(['xpath' => "//div[@id='" . $id . "_chzn']//ul[@class='chzn-results']/li[contains(.,'" . $value . "')]"]);
864+
$I->selectOptionInChosenByIdUsingJs($id, $value);
839865
}
840866
}
841867
$I->debug('Applied filters');

0 commit comments

Comments
 (0)