Skip to content

Commit 0d01885

Browse files
author
Aponasenko, Dmytro(daponasenko)
committed
Merge pull request #378 from magento-qmt/develop
[Mavericks] Add a wait to form element before filling a value and functional tests maintenance
2 parents 7eed0be + 3af16a4 commit 0d01885

File tree

102 files changed

+896
-1438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+896
-1438
lines changed

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc26",
3+
"magento/mtf": "1.0.0-rc27",
44
"php": "~5.5.0|~5.6.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/lib/Magento/Mtf/Client/Element/GlobalsearchElement.php

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
*/
1515
class GlobalsearchElement extends SimpleElement
1616
{
17-
/**
18-
* "Backspace" key code.
19-
*/
20-
const BACKSPACE = "\xEE\x80\x83";
21-
2217
/**
2318
* Search icon selector.
2419
*
@@ -63,43 +58,14 @@ class GlobalsearchElement extends SimpleElement
6358
public function setValue($value)
6459
{
6560
$this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
66-
6761
$this->waitInitElement();
68-
6962
if (!$this->find($this->searchInput)->isVisible()) {
7063
$this->find($this->searchIcon)->click();
7164
}
72-
$this->selectWindow();
73-
$this->clear();
74-
$this->find($this->searchInput)->setValue($value);
75-
$this->selectWindow();
76-
65+
$this->find($this->searchInput)->keys(str_split($value));
7766
$this->waitResult();
7867
}
7968

80-
/**
81-
* Clear value of element.
82-
*
83-
* @return void
84-
*/
85-
protected function clear()
86-
{
87-
$element = $this->find($this->searchInput);
88-
while ('' != $element->getValue()) {
89-
$element->setValue([self::BACKSPACE]);
90-
}
91-
}
92-
93-
/**
94-
* Select to last window.
95-
*
96-
* @return void
97-
*/
98-
protected function selectWindow()
99-
{
100-
$this->driver->selectWindow();
101-
}
102-
10369
/**
10470
* Wait init search suggest container.
10571
*
@@ -130,12 +96,7 @@ public function waitResult()
13096

13197
$this->driver->waitUntil(
13298
function () use ($browser, $selector) {
133-
if ($browser->find($selector)->isVisible()) {
134-
return true;
135-
} else {
136-
$browser->selectWindow();
137-
return null;
138-
}
99+
return $browser->find($selector)->isVisible() ? true : null;
139100
}
140101
);
141102
}

dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Magento\Backend\Test\Block\System\Config\Form;
1010

1111
use Magento\Mtf\Client\Locator;
12-
use Magento\Backend\Test\Block\Widget\Form;
12+
use Magento\Mtf\Block\Form;
1313

1414
/**
1515
* Class Group

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Form.php

Lines changed: 0 additions & 199 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Backend\Test\Block\Widget;
88

99
use Magento\Mtf\Block\BlockFactory;
10+
use Magento\Mtf\Block\Form;
1011
use Magento\Mtf\Block\Mapper;
1112
use Magento\Mtf\Client\Locator;
1213
use Magento\Mtf\Client\ElementInterface;
@@ -87,8 +88,7 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
8788
foreach ($tabs as $tabName => $tabFields) {
8889
$tab = $this->getTab($tabName);
8990
$this->openTab($tabName);
90-
$tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
91-
$this->updateUnassignedFields($tab);
91+
$tab->fillFormTab($tabFields, $context);
9292
}
9393
if (!empty($this->unassignedFields)) {
9494
$this->fillMissedFields($tabs);
@@ -97,34 +97,25 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
9797
return $this;
9898
}
9999

100-
/**
101-
* Update array with fields which aren't assigned to any tab
102-
*
103-
* @param Tab $tab
104-
*/
105-
protected function updateUnassignedFields(Tab $tab)
106-
{
107-
$this->unassignedFields = array_diff_key(
108-
$this->unassignedFields,
109-
array_intersect_key($this->unassignedFields, $tab->setFields)
110-
);
111-
}
112-
113100
/**
114101
* Fill fields which weren't found on filled tabs
115102
*
116-
* @param array $tabs
117103
* @throws \Exception
118-
*
119104
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
120105
*/
121-
protected function fillMissedFields(array $tabs)
106+
protected function fillMissedFields()
122107
{
123-
foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) {
108+
foreach ($this->tabs as $tabName => $tabData) {
124109
$tab = $this->getTab($tabName);
125-
if ($this->openTab($tabName)) {
126-
$tab->fillFormTab($this->unassignedFields, $this->_rootElement);
127-
$this->updateUnassignedFields($tab);
110+
if ($this->openTab($tabName) && $this->isTabVisible($tabName)) {
111+
$mapping = $tab->dataMapping($this->unassignedFields);
112+
foreach ($mapping as $fieldName => $data) {
113+
$element = $tab->_rootElement->find($data['selector'], $data['strategy'], $data['input']);
114+
if ($element->isVisible()) {
115+
$element->setValue($data['value']);
116+
unset($this->unassignedFields[$fieldName]);
117+
}
118+
}
128119
if (empty($this->unassignedFields)) {
129120
break;
130121
}

0 commit comments

Comments
 (0)