Skip to content

Commit 0987a02

Browse files
authored
Merge pull request #1348 from magento-tsg/2.1.8-develop-pr23
[TSG] Backporting for 2.1 (pr23) (2.1.8)
2 parents 64fe924 + cd1d357 commit 0987a02

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
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-rc47",
3+
"magento/mtf": "2.1.x-dev",
44
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2"

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function () {
5050
*/
5151
public function fillFormData(array $data)
5252
{
53+
$this->waitLoader();
5354
$data = $this->prepareData($data);
5455
if (isset($data['form_data'])) {
5556
$data['form_data'] = $this->dataMapping($data['form_data']);

dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\User\Test\TestStep;
88

99
use Magento\Backend\Test\Page\AdminAuthLogin;
10+
use Magento\Mtf\Client\BrowserInterface;
1011
use Magento\Mtf\TestStep\TestStepInterface;
1112
use Magento\User\Test\Fixture\User;
1213
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
@@ -44,23 +45,43 @@ class LoginUserOnBackendStep implements TestStepInterface
4445
*/
4546
protected $dashboard;
4647

48+
/**
49+
* Browser.
50+
*
51+
* @var BrowserInterface
52+
*/
53+
private $browser;
54+
55+
/**
56+
* Array of error messages on admin login form.
57+
*
58+
* @var array
59+
*/
60+
private $errorMessages = [
61+
'Invalid Form Key. Please refresh the page.',
62+
'Your current session has been expired.',
63+
];
64+
4765
/**
4866
* @constructor
4967
* @param LogoutUserOnBackendStep $logoutUserOnBackendStep
5068
* @param AdminAuthLogin $adminAuth
5169
* @param User $user
5270
* @param Dashboard $dashboard
71+
* @param BrowserInterface $browser
5372
*/
5473
public function __construct(
5574
LogoutUserOnBackendStep $logoutUserOnBackendStep,
5675
AdminAuthLogin $adminAuth,
5776
User $user,
58-
Dashboard $dashboard
77+
Dashboard $dashboard,
78+
BrowserInterface $browser
5979
) {
6080
$this->logoutUserOnBackendStep = $logoutUserOnBackendStep;
6181
$this->adminAuth = $adminAuth;
6282
$this->user = $user;
6383
$this->dashboard = $dashboard;
84+
$this->browser = $browser;
6485
}
6586

6687
/**
@@ -76,10 +97,25 @@ public function run()
7697
$this->logoutUserOnBackendStep->run();
7798
}
7899

100+
try {
101+
$this->login();
102+
} catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
103+
if (strpos($e->getMessage(), 'Timed out after') !== false) {
104+
$messages = $this->adminAuth->getMessagesBlock();
105+
if (in_array($messages->getErrorMessage(), $this->errorMessages, true)) {
106+
$this->browser->refresh();
107+
$this->login();
108+
}
109+
}
110+
}
111+
112+
$this->dashboard->getSystemMessageDialog()->closePopup();
113+
}
114+
115+
private function login()
116+
{
79117
$this->adminAuth->getLoginBlock()->fill($this->user);
80118
$this->adminAuth->getLoginBlock()->submit();
81119
$this->adminAuth->getLoginBlock()->waitFormNotVisible();
82-
83-
$this->dashboard->getSystemMessageDialog()->closePopup();
84120
}
85121
}

0 commit comments

Comments
 (0)