File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed
lib/Magento/Mtf/Client/Element
tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/ProductDetails Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,21 @@ public function setValue($value)
75
75
if ($ value == '' ) {
76
76
return ;
77
77
}
78
+ $ this ->selectSearchedItem ($ value );
79
+ $ closeButton = $ this ->find ($ this ->closeButton );
80
+ if ($ closeButton ->isVisible ()) {
81
+ $ closeButton ->click ();
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Select searched item.
87
+ *
88
+ * @param string $value
89
+ * @return void
90
+ */
91
+ protected function selectSearchedItem ($ value )
92
+ {
78
93
foreach (str_split ($ value ) as $ symbol ) {
79
94
$ this ->keys ([$ symbol ]);
80
95
$ searchedItem = $ this ->find (sprintf ($ this ->resultItem , $ value ), Locator::SELECTOR_XPATH );
@@ -88,10 +103,6 @@ public function setValue($value)
88
103
}
89
104
}
90
105
}
91
- $ closeButton = $ this ->find ($ this ->closeButton );
92
- if ($ closeButton ->isVisible ()) {
93
- $ closeButton ->click ();
94
- }
95
106
}
96
107
97
108
/**
Original file line number Diff line number Diff line change 7
7
namespace Magento \Catalog \Test \Block \Adminhtml \Product \Edit \Section \ProductDetails ;
8
8
9
9
use Magento \Mtf \Client \Element \MultisuggestElement ;
10
+ use Magento \Mtf \Client \Locator ;
10
11
11
12
/**
12
13
* Typified element class for category element.
@@ -21,14 +22,22 @@ class CategoryIds extends MultisuggestElement
21
22
protected $ resultItem = './/label[contains(@class, "admin__action-multiselect-label")]/span[text() = "%s"] ' ;
22
23
23
24
/**
24
- * Set value .
25
+ * Select searched item .
25
26
*
26
- * @param array| string $values
27
+ * @param string $value
27
28
* @return void
28
29
*/
29
- public function setValue ( $ values )
30
+ protected function selectSearchedItem ( $ value )
30
31
{
31
- $ this ->getContext ()->hover ();
32
- parent ::setValue ($ values );
32
+ $ this ->keys ([$ value ]);
33
+ $ searchedItem = $ this ->find (sprintf ($ this ->resultItem , $ value ), Locator::SELECTOR_XPATH );
34
+ if ($ searchedItem ->isVisible ()) {
35
+ try {
36
+ $ searchedItem ->click ();
37
+ } catch (\Exception $ e ) {
38
+ // In parallel run on windows change the focus is lost on element
39
+ // that causes disappearing of category suggest list.
40
+ }
41
+ }
33
42
}
34
43
}
You can’t perform that action at this time.
0 commit comments