Skip to content

Commit ce5868b

Browse files
MTA-3285: Extend simple product search
1 parent 0c2bf8c commit ce5868b

File tree

1 file changed

+20
-12
lines changed
  • dev/tests/functional/tests/app/Magento/Catalog/Test/Block

1 file changed

+20
-12
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Search.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class Search extends Block
5555
*
5656
* @var string
5757
*/
58-
protected $searchListItems = './/div[@id="search_autocomplete"]//li';
58+
private $searchListItems = './/div[@id="search_autocomplete"]//li';
5959

6060
/**
6161
* Locator value for body with aria-busy attribute.
6262
*
6363
* @var string
6464
*/
65-
protected $selectorAriaBusy = './/body[@aria-busy="false"]';
65+
private $selectorAriaBusy = './/body[@aria-busy="false"]';
6666

6767
/**
6868
* Perform search by a keyword.
@@ -87,16 +87,25 @@ public function search($keyword)
8787
public function fillSearch($text)
8888
{
8989
$this->_rootElement->find($this->searchInput)->setValue($text);
90-
$searchListItems = $this->searchListItems;
91-
$selectorAriaBusy = $this->selectorAriaBusy;
92-
$browser = $this->browser;
93-
$browser->waitUntil(
94-
function () use ($searchListItems, $browser, $selectorAriaBusy) {
95-
$count = count($this->_rootElement->getElements($searchListItems, Locator::SELECTOR_XPATH));
90+
$this->waitUntilSearchPrepared();
91+
}
92+
93+
/**
94+
* Wait until "Suggest Search" block will be prepared.
95+
*
96+
* @return bool
97+
*/
98+
public function waitUntilSearchPrepared()
99+
{
100+
$this->browser->waitUntil(
101+
function () {
102+
$count = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
96103
sleep(0.2);
97-
return $browser->find($selectorAriaBusy, Locator::SELECTOR_XPATH)->isVisible() &&
98-
count($this->_rootElement->getElements($searchListItems, Locator::SELECTOR_XPATH)) == $count
99-
? true : null;
104+
$newCount = count($this->_rootElement->getElements($this->searchListItems, Locator::SELECTOR_XPATH));
105+
return $this->browser->find($this->selectorAriaBusy, Locator::SELECTOR_XPATH)->isVisible()
106+
&& ($newCount == $count)
107+
? true
108+
: null;
100109
}
101110
);
102111
}
@@ -144,7 +153,6 @@ function () use ($rootElement, $searchAutocomplete) {
144153
public function clickSuggestedText($text)
145154
{
146155
$searchAutocomplete = sprintf($this->searchAutocomplete, $text);
147-
$this->waitForElementVisible($searchAutocomplete, Locator::SELECTOR_XPATH);
148156
$this->_rootElement->find($searchAutocomplete, Locator::SELECTOR_XPATH)->click();
149157
}
150158
}

0 commit comments

Comments
 (0)