From 4b613da0d6a28d9afcdd33ec00556b4dca199dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 8 May 2023 16:54:51 +0200 Subject: [PATCH] add bool filter Behat test --- src/Behat/Context.php | 8 +++++--- tests-behat/filter.feature | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Behat/Context.php b/src/Behat/Context.php index ffa8b0af74..971e8e88b7 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -361,7 +361,7 @@ public function iClickUsingSelector(string $selector): void */ public function iClickPaginatorPage(string $pageNumber): void { - $element = $this->findElement(null, 'a.item[data-page=' . $pageNumber . ']'); + $element = $this->findElement(null, 'a.item[data-page="' . $pageNumber . '"]'); $element->click(); } @@ -542,8 +542,10 @@ public function iSearchGridFor(string $text): void */ public function iSelectValueInLookup(string $value, string $inputName): void { + $isXpath = $this->parseSelector($inputName)[0] === 'xpath'; + // get dropdown item from Fomantic-UI which is direct parent of input html element - $lookupElem = $this->findElement(null, '//input[@name="' . $inputName . '"]/parent::div'); + $lookupElem = $this->findElement(null, ($isXpath ? $inputName : '//input[@name="' . $inputName . '"]') . '/parent::div'); // open dropdown and wait till fully opened (just a click is not triggering it) $this->getSession()->executeScript('$(arguments[0]).dropdown(\'show\')', [$lookupElem]); @@ -551,7 +553,7 @@ public function iSelectValueInLookup(string $value, string $inputName): void // select value $valueElem = $this->findElement($lookupElem, '//div[text()="' . $value . '"]'); - $this->getSession()->executeScript('$(arguments[0]).dropdown(\'set selected\', ' . $valueElem->getAttribute('data-value') . ');', [$lookupElem]); + $this->getSession()->executeScript('$(arguments[0]).dropdown(\'set selected\', arguments[1]);', [$lookupElem, $valueElem->getAttribute('data-value')]); $this->jqueryWait(); // hide dropdown and wait till fully closed diff --git a/tests-behat/filter.feature b/tests-behat/filter.feature index 9a8858f204..e2621cc96f 100644 --- a/tests-behat/filter.feature +++ b/tests-behat/filter.feature @@ -21,6 +21,14 @@ Feature: Table Filter When I click using selector "//div.popup[5]//div[text()='Clear']" Then I should not see "No records" Then I should see "United Kingdom" + Then I click filter column name "is_uk" + Then I select value "Is No" in lookup "//div.popup[6]//input[@name='op']" + When I click using selector "//div.popup[6]//div[text()='Set']" + Then I should see "No records" + Then I click filter column name "is_uk" + Then I select value "Is Yes" in lookup "//div.popup[6]//input[@name='op']" + When I click using selector "//div.popup[6]//div[text()='Set']" + Then I should see "United Kingdom" Then I press menu button "Clear Filters" using selector ".ui.menu.atk-grid-menu" Then I should not see "United Kingdom" Then I should see "Australia"