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 \BrowserInterface ;
10
11
use Magento \Mtf \Client \Locator ;
12
+ use Magento \Mtf \Client \DriverInterface ;
13
+ use Magento \Mtf \Client \ElementInterface ;
14
+ use Magento \Mtf \System \Event \EventManagerInterface ;
11
15
12
16
/**
13
17
* Typified element class for category element.
@@ -22,22 +26,53 @@ class CategoryIds extends MultisuggestElement
22
26
protected $ resultItem = './/label[contains(@class, "admin__action-multiselect-label")]/span[text() = "%s"] ' ;
23
27
24
28
/**
25
- * Select searched item .
29
+ * Browser instance .
26
30
*
27
- * @param string $value
28
- * @return void
31
+ * @var BrowserInterface
29
32
*/
30
- protected function selectSearchedItem ($ value )
33
+ protected $ browser ;
34
+
35
+ /**
36
+ * Locator for page footer.
37
+ *
38
+ * @var string
39
+ */
40
+ protected $ pageFooter = '.page-footer ' ;
41
+
42
+ /**
43
+ * Locator for advanced inventory button.
44
+ *
45
+ * @var string
46
+ */
47
+ protected $ advancedInventoryButton = '[data-index="advanced_inventory_button"] ' ;
48
+
49
+ /**
50
+ * @param BrowserInterface $browser
51
+ * @param DriverInterface $driver
52
+ * @param EventManagerInterface $eventManager
53
+ * @param Locator $locator
54
+ * @param ElementInterface $context
55
+ */
56
+ public function __construct (
57
+ BrowserInterface $ browser ,
58
+ DriverInterface $ driver ,
59
+ EventManagerInterface $ eventManager ,
60
+ Locator $ locator ,
61
+ ElementInterface $ context = null
62
+ ) {
63
+ $ this ->browser = $ browser ;
64
+ parent ::__construct ($ driver , $ eventManager , $ locator , $ context );
65
+ }
66
+
67
+ /**
68
+ * Set category value.
69
+ *
70
+ * @param array|string $value
71
+ */
72
+ public function setValue ($ value )
31
73
{
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
- }
74
+ $ this ->browser ->find ($ this ->pageFooter )->hover ();
75
+ $ this ->browser ->find ($ this ->advancedInventoryButton )->hover ();
76
+ parent ::setValue ($ value );
42
77
}
43
78
}
0 commit comments