Skip to content

Commit e9b5b0d

Browse files
Manjusha.SManjusha.S
Manjusha.S
authored and
Manjusha.S
committed
MQE-1518 : Added new action WaitForElementClickable
1 parent 6fc5d26 commit e9b5b0d

File tree

5 files changed

+151
-1
lines changed

5 files changed

+151
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Description("<h3>Test files</h3>vendor/magento/module-page-builder/Test/Mftf/Test/AdminPageBuilderColumnTest/WaitForElementClickableTest.xml<br>")
17+
*/
18+
class WaitForElementClickableTest
19+
{
20+
/**
21+
* @param AcceptanceTester $I
22+
* @throws \Exception
23+
*/
24+
public function _before(AcceptanceTester $I)
25+
{
26+
$I->comment("Entering Action Group [loginAsAdmin] AdminLoginActionGroup");
27+
$I->amOnPage((getenv("MAGENTO_BACKEND_BASE_URL") ? rtrim(getenv("MAGENTO_BACKEND_BASE_URL"), "/") : "") . "/" . getenv("MAGENTO_BACKEND_NAME") . "/admin"); // stepKey: navigateToAdminLoginAsAdmin
28+
$I->fillField("#username", getenv("MAGENTO_ADMIN_USERNAME")); // stepKey: fillUsernameLoginAsAdmin
29+
$I->fillField("#login", getenv("MAGENTO_ADMIN_PASSWORD")); // stepKey: fillPasswordLoginAsAdmin
30+
$I->click(".actions .action-primary"); // stepKey: clickLoginLoginAsAdmin
31+
$I->waitForPageLoad(30); // stepKey: clickLoginLoginAsAdminWaitForPageLoad
32+
$I->conditionalClick(".modal-popup .action-secondary", ".modal-popup .action-secondary", true); // stepKey: clickDontAllowButtonIfVisibleLoginAsAdmin
33+
$I->closeAdminNotification(); // stepKey: closeAdminNotificationLoginAsAdmin
34+
$I->comment("Exiting Action Group [loginAsAdmin] AdminLoginActionGroup");
35+
}
36+
37+
/**
38+
* @param AcceptanceTester $I
39+
* @throws \Exception
40+
*/
41+
public function _after(AcceptanceTester $I)
42+
{
43+
$I->comment("Entering Action Group [logout] AdminLogoutActionGroup");
44+
$I->amOnPage((getenv("MAGENTO_BACKEND_BASE_URL") ? rtrim(getenv("MAGENTO_BACKEND_BASE_URL"), "/") : "") . "/" . getenv("MAGENTO_BACKEND_NAME") . "/admin/auth/logout/"); // stepKey: amOnLogoutPageLogout
45+
$I->comment("Exiting Action Group [logout] AdminLogoutActionGroup");
46+
}
47+
48+
/**
49+
* @param AcceptanceTester $I
50+
* @throws \Exception
51+
*/
52+
public function _failed(AcceptanceTester $I)
53+
{
54+
$I->saveScreenshot(); // stepKey: saveScreenshot
55+
}
56+
57+
/**
58+
* @Features({"PageBuilder"})
59+
* @param AcceptanceTester $I
60+
* @return void
61+
* @throws \Exception
62+
*/
63+
public function WaitForElementClickableTest(AcceptanceTester $I)
64+
{
65+
$I->moveMouseOver("(//div[@data-content-type=\"column\"])[1]"); // stepKey: moveMouseOverColumn
66+
$I->waitForPageLoad(30); // stepKey: waitForMouseOver
67+
$I->waitForElementClickable("(//div[contains(@class, \"pagebuilder-content-type\") and contains(@class, \"pagebuilder-column\")])[1]//div[contains(@class,\"pagebuilder-options-visible\")]"); // stepKey: waitForOptions
68+
}
69+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="WaitForElementClickableTest">
11+
12+
<before>
13+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
14+
</before>
15+
<after>
16+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
17+
</after>
18+
<moveMouseOver selector="{{ColumnOnBackend.base('1')}}" stepKey="moveMouseOverColumn"/>
19+
<waitForPageLoad stepKey="waitForMouseOver"/>
20+
<waitForElementClickable selector="{{PageBuilderContentTypeOptionsMenu.contentTypeOptionsMenuByIndex(PageBuilderColumnContentType.role, '1')}}" stepKey="waitForOptions"/>
21+
</test>
22+
</tests>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\verification\Tests;
7+
8+
use tests\util\MftfTestCase;
9+
10+
class WaitForElementClickableTest extends MftfTestCase
11+
{
12+
/**
13+
* WaitForElementClickable:
14+
* Tests flat generation of a hardcoded test file with no external references.
15+
*
16+
* @throws \Exception
17+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
18+
*/
19+
public function testWaitForElementClickableAction()
20+
{
21+
$this->generateAndCompareTest('WaitForElementClickableTest');
22+
}
23+
24+
}

docs/test/actions.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,10 +2374,28 @@ Attribute|Type|Use|Description
23742374
#### Example
23752375

23762376
```xml
2377-
<!-- Wait up to 30 seconds for `<div id="changedElement" ... >...</div>` to become visible on the page before continuing. -->
23782377
<waitForElementVisible selector="#changedElement" stepKey="waitForElementVisible"/>
23792378
```
23802379

2380+
### waitForElementClickable
2381+
2382+
See [waitForElementClickable docs on codeception.com](http://codeception.com/docs/modules/WebDriver#waitForElementClickable).
2383+
2384+
Attribute|Type|Use|Description
2385+
---|---|---|---
2386+
`selector`|string|optional| The selector identifying the corresponding HTML element.
2387+
`time`|string|optional| The number of seconds to wait for the element to appear.
2388+
`stepKey`|string|required| A unique identifier of the action.
2389+
`before`|string|optional| `stepKey` of action that must be executed next.
2390+
`after`|string|optional| `stepKey` of preceding action.
2391+
2392+
#### Example
2393+
2394+
```xml
2395+
<!-- Waits up to $timeout seconds for the given element to be clickable. If element doesn’t become clickable, a timeout exception is thrown. -->
2396+
<waitForElementClickable selector="#changedElement" stepKey="waitForElementClickable"/>
2397+
```
2398+
23812399
### waitForJS
23822400

23832401
See [waitForJS docs on codeception.com](http://codeception.com/docs/modules/WebDriver#waitForJS).

src/Magento/FunctionalTestingFramework/Test/etc/Actions/waitActions.xsd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<xs:element type="waitForPwaElementNotVisibleType" name="waitForPwaElementNotVisible" minOccurs="0" maxOccurs="unbounded"/>
2424
<xs:element type="waitForPwaElementVisibleType" name="waitForPwaElementVisible" minOccurs="0" maxOccurs="unbounded"/>
2525
<xs:element type="waitForTextType" name="waitForText" minOccurs="0" maxOccurs="unbounded"/>
26+
<xs:element type="waitForElementClickableType" name="waitForElementClickable" minOccurs="0" maxOccurs="unbounded"/>
27+
2628
</xs:choice>
2729
</xs:group>
2830

@@ -224,4 +226,19 @@
224226
</xs:extension>
225227
</xs:simpleContent>
226228
</xs:complexType>
229+
<xs:complexType name="waitForElementClickableType">
230+
<xs:annotation>
231+
<xs:documentation>
232+
Waits up to $timeout seconds for the given element to be clickable.
233+
If element doesn’t become clickable, a timeout exception is thrown.
234+
</xs:documentation>
235+
</xs:annotation>
236+
<xs:simpleContent>
237+
<xs:extension base="xs:string">
238+
<xs:attribute ref="selector" use="required"/>
239+
<xs:attribute ref="time"/>
240+
<xs:attributeGroup ref="commonActionAttributes"/>
241+
</xs:extension>
242+
</xs:simpleContent>
243+
</xs:complexType>
227244
</xs:schema>

0 commit comments

Comments
 (0)