8
8
namespace Magento \Backend \Test \Block \System \Config ;
9
9
10
10
use Magento \Mtf \Factory \Factory ;
11
- use Magento \Mtf \Block \BlockFactory ;
12
11
use Magento \Mtf \Block \Block ;
13
- use Magento \Mtf \Client \ElementInterface ;
14
- use Magento \Mtf \Client \BrowserInterface ;
15
12
use Magento \Mtf \Client \Locator ;
16
13
17
14
/**
@@ -54,26 +51,6 @@ class Form extends Block
54
51
*/
55
52
protected $ baseUrl ;
56
53
57
- /**
58
- * @constructor
59
- * @param ElementInterface $element
60
- * @param BlockFactory $blockFactory
61
- * @param BrowserInterface $browser
62
- * @param array $config
63
- */
64
- public function __construct (
65
- ElementInterface $ element ,
66
- BlockFactory $ blockFactory ,
67
- BrowserInterface $ browser ,
68
- array $ config = []
69
- ) {
70
- parent ::__construct ($ element , $ blockFactory , $ browser , $ config );
71
- $ this ->baseUrl = $ this ->browser ->getUrl ();
72
- if (substr ($ this ->baseUrl , -1 ) !== '/ ' ) {
73
- $ this ->baseUrl = $ this ->baseUrl . '/ ' ;
74
- }
75
- }
76
-
77
54
/**
78
55
* Obtain store configuration form group.
79
56
*
@@ -83,7 +60,13 @@ public function __construct(
83
60
*/
84
61
public function getGroup ($ tabName , $ groupName )
85
62
{
86
- $ tabUrl = $ this ->baseUrl . 'section/ ' . $ tabName ;
63
+ $ this ->baseUrl = $ this ->getBrowserUrl ();
64
+ if (substr ($ this ->baseUrl , -1 ) !== '/ ' ) {
65
+ $ this ->baseUrl = $ this ->baseUrl . '/ ' ;
66
+ }
67
+
68
+ $ tabUrl = $ this ->getTabUrl ($ tabName );
69
+
87
70
if ($ this ->getBrowserUrl () !== $ tabUrl ) {
88
71
$ this ->browser ->open ($ tabUrl );
89
72
}
@@ -127,4 +110,30 @@ public function save()
127
110
{
128
111
$ this ->_rootElement ->find ($ this ->saveButton , Locator::SELECTOR_CSS )->click ();
129
112
}
113
+
114
+ /**
115
+ * Checks whether secret key is presented in base url and returns menu tab url.
116
+ *
117
+ * @param string $tabName
118
+ * @return string
119
+ */
120
+ private function getTabUrl ($ tabName )
121
+ {
122
+ $ tabIndex = 'index/section/ ' . $ tabName ;
123
+ if (strpos ($ this ->baseUrl , '/key/ ' ) !== false ) {
124
+ /*
125
+ * Slashes are concatenated to cover case when string 'index' presented in domain name
126
+ * or somewhere else in url additionally.
127
+ */
128
+ $ tabUrl = str_replace ('/index/ ' , '/ ' . $ tabIndex . '/ ' , $ this ->baseUrl );
129
+ }
130
+ elseif (strpos ($ this ->baseUrl , '/edit/ ' ) !== false ) {
131
+ $ tabUrl = str_replace ('/edit/ ' , '/ ' . $ tabIndex . '/ ' , $ this ->baseUrl );
132
+ }
133
+ else {
134
+ $ tabUrl = $ this ->baseUrl . $ tabIndex ;
135
+ }
136
+
137
+ return $ tabUrl ;
138
+ }
130
139
}
0 commit comments