Skip to content

Commit 1471e9e

Browse files
committed
Merge pull request #73 from puneet0191/SetFilter
Adding a function to set Filters in Joomla! admin panel
2 parents 0b43acd + 033f553 commit 1471e9e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/JoomlaBrowser.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ public function clickToolbarButton($button)
722722
case "cancel":
723723
$I->click(['xpath' => "//div[@id='toolbar-cancel']//button"]);
724724
break;
725+
case "empty trash":
726+
$I->click(['xpath' => "//div[@id='toolbar-delete']//button"]);
727+
break;
725728
}
726729
}
727730

@@ -780,4 +783,37 @@ public function createMenuItem($menuTitle, $menuCategory, $menuItem, $menu = 'Ma
780783

781784
$I->waitForText('Menu item successfully saved', '60', ['id' => 'system-message-container']);
782785
}
786+
787+
/**
788+
* Function to filter results in Joomla! Administrator.
789+
*
790+
* @param string $label Label of the Filter you want to use.
791+
* @param string $value Value you want to set in the filters.
792+
*
793+
* @return void
794+
*/
795+
public function setFilter($label, $value)
796+
{
797+
$label = strtolower($label);
798+
$filters = array(
799+
"select status" => "filter_published",
800+
"select access" => "filter_access",
801+
"select language" => "filter_language",
802+
"select tag" => "filter_tag",
803+
"select max levels" => "filter_level"
804+
);
805+
$I = $this;
806+
$I->click(['xpath' => "//button[@data-original-title='Filter the list items.']"]);
807+
$I->debug('I try to select the filters');
808+
foreach($filters as $fieldName => $id)
809+
{
810+
if($fieldName == $label)
811+
{
812+
$I->waitForElement(['xpath' => "//div[@id='" . $id . "_chzn']/a"], 10);
813+
$I->click(['xpath' => "//div[@id='" . $id . "_chzn']/a"]);
814+
$I->click(['xpath' => "//div[@id='" . $id . "_chzn']//ul[@class='chzn-results']/li[contains(.,'" . $value . "')]"]);
815+
}
816+
}
817+
$I->debug('Applied filters');
818+
}
783819
}

0 commit comments

Comments
 (0)