Skip to content

Commit e13741e

Browse files
committed
MQE-1994: Refactor MFTF tests/actionGroups that need custom actions
1 parent dadef8a commit e13741e

File tree

2 files changed

+103
-30
lines changed

2 files changed

+103
-30
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\PageBuilder\Test\Mftf\Helper;
8+
9+
use Magento\FunctionalTestingFramework\Helper\Helper;
10+
use Magento\Tests\NamingConvention\true\string;
11+
12+
/**
13+
* Class SelectText provides an ability to select needed text.
14+
*/
15+
class SelectText extends Helper
16+
{
17+
/**
18+
* Select needed text.
19+
*
20+
* @param string $context
21+
* @param string $startX
22+
* @param string $startY
23+
* @param string $endX
24+
* @param string $endY
25+
* @return void
26+
*/
27+
public function selectText(string $context, string $startX, string $startY, string $endX, string $endY)
28+
{
29+
try {
30+
/** @var \Magento\FunctionalTestingFramework\Module\MagentoWebDriver $webDriver */
31+
$webDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
32+
33+
$contextElement = $webDriver->webDriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath($context));
34+
$actions = new \Facebook\WebDriver\Interactions\WebDriverActions($webDriver->webDriver);
35+
$actions->moveToElement($contextElement, $startX, $startY)
36+
->clickAndHold()
37+
->moveToElement($contextElement, $endX, $endY)
38+
->release()
39+
->perform();
40+
} catch (\Exception $e) {
41+
$this->fail($e->getMessage());
42+
}
43+
}
44+
45+
/**
46+
* Select needed text between 2 context elements.
47+
*
48+
* @param string $firstContext
49+
* @param string $secondContext
50+
* @param string $startX
51+
* @param string $startY
52+
* @param string $endX
53+
* @param string $endY
54+
* @return void
55+
*/
56+
public function selectHeadingTextAndVariableTinyMCE(
57+
string $firstContext,
58+
string $secondContext,
59+
string $startX,
60+
string $startY,
61+
string $endX,
62+
string $endY
63+
) {
64+
try {
65+
/** @var \Magento\FunctionalTestingFramework\Module\MagentoWebDriver $webDriver */
66+
$webDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');
67+
68+
$heading = $webDriver->webDriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath($firstContext));
69+
$text = $webDriver->webDriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath($secondContext));
70+
$actions = new \Facebook\WebDriver\Interactions\WebDriverActions($webDriver->webDriver);
71+
$actions->moveToElement($heading, $startX, $startY)
72+
->clickAndHold()
73+
->moveToElement($text, $endX, $endY)
74+
->release()
75+
->perform();
76+
} catch (\Exception $e) {
77+
$this->fail($e->getMessage());
78+
}
79+
}
80+
}

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderTextTest/TextVerifySelectionInlineWYSIWYG.xml

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
<testCaseId value="MC-29450"/>
1919
<group value="pagebuilder"/>
2020
<group value="pagebuilder-text"/>
21-
<!-- skip due to MQE-1964 -->
22-
<group value="skip"/>
2321
</annotations>
2422
<before>
2523
<createData entity="_defaultCmsPage" stepKey="createCMSPage"/>
@@ -64,15 +62,13 @@
6462
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
6563
<actionGroup ref="scrollToTinyMCE" stepKey="scrollToTinyMCE"/>
6664
<!-- Select portion of Heading "his is a h" -->
67-
<!--<executeInSelenium function="function ($webdriver) use ($I) {-->
68-
<!--$heading = $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath('//div[contains(@class, \'inline-wysiwyg\')]//h2'));-->
69-
<!--$actions = new \Facebook\WebDriver\Interactions\WebDriverActions($webdriver);-->
70-
<!--$actions->moveToElement($heading, {{TinyMCEPartialHeadingSelection.startX}}, {{TinyMCEPartialHeadingSelection.startY}})-->
71-
<!-- ->clickAndHold()-->
72-
<!-- ->moveToElement($heading, {{TinyMCEPartialHeadingSelection.endX}}, {{TinyMCEPartialHeadingSelection.endY}})-->
73-
<!-- ->release()-->
74-
<!-- ->perform();-->
75-
<!--}" stepKey="selectHeadingTextInTinyMCE"/>-->
65+
<helper class="\Magento\User\Test\Mftf\Helper\SelectText" method="selectText" stepKey="selectHeadingTextInTinyMCE">
66+
<argument name="context">//div[contains(@class, 'inline-wysiwyg')]//h2</argument>
67+
<argument name="startX">{{TinyMCEPartialHeadingSelection.startX}}</argument>
68+
<argument name="startY">{{TinyMCEPartialHeadingSelection.startY}}</argument>
69+
<argument name="endX">{{TinyMCEPartialHeadingSelection.endX}}</argument>
70+
<argument name="endY">{{TinyMCEPartialHeadingSelection.endY}}</argument>
71+
</helper>
7672
<actionGroup ref="waitForTinyMCEInFocus" stepKey="waitForTinyMCEInFocus"/>
7773
<actionGroup ref="assertSelectedText" stepKey="assertSelection">
7874
<argument name="expectedSelectedText" value="TinyMCEPartialHeadingSelection"/>
@@ -82,15 +78,13 @@
8278
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage2"/>
8379
<actionGroup ref="scrollToTinyMCE" stepKey="scrollToTinyMCE2"/>
8480
<!-- Select portion of paragraph text "es stri" -->
85-
<!--<executeInSelenium function="function ($webdriver) use ($I) {-->
86-
<!--$text = $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath('//div[contains(@class, \'inline-wysiwyg\')]//p[2]'));-->
87-
<!--$actions = new \Facebook\WebDriver\Interactions\WebDriverActions($webdriver);-->
88-
<!--$actions->moveToElement($text, {{TinyMCEPartialTextSelection.startX}}, {{TinyMCEPartialTextSelection.startY}})-->
89-
<!-- ->clickAndHold()-->
90-
<!-- ->moveToElement($text, {{TinyMCEPartialTextSelection.endX}}, {{TinyMCEPartialTextSelection.endY}})-->
91-
<!-- ->release()-->
92-
<!-- ->perform();-->
93-
<!--}" stepKey="selectTextInTinyMCE"/>-->
81+
<helper class="\Magento\User\Test\Mftf\Helper\SelectText" method="selectText" stepKey="selectTextInTinyMCE">
82+
<argument name="context">//div[contains(@class, 'inline-wysiwyg')]//p[2]</argument>
83+
<argument name="startX">{{TinyMCEPartialTextSelection.startX}}</argument>
84+
<argument name="startY">{{TinyMCEPartialTextSelection.startY}}</argument>
85+
<argument name="endX">{{TinyMCEPartialTextSelection.endX}}</argument>
86+
<argument name="endY">{{TinyMCEPartialTextSelection.endY}}</argument>
87+
</helper>
9488
<actionGroup ref="waitForTinyMCEInFocus" stepKey="waitForTinyMCEInFocus2"/>
9589
<actionGroup ref="assertSelectedText" stepKey="assertSelection2">
9690
<argument name="expectedSelectedText" value="TinyMCEPartialTextSelection"/>
@@ -100,16 +94,15 @@
10094
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage3"/>
10195
<actionGroup ref="scrollToTinyMCE" stepKey="scrollToTinyMCE3"/>
10296
<!-- Select from part of the heading, over the variable, to part of the text string -->
103-
<!--<executeInSelenium function="function ($webdriver) use ($I) {-->
104-
<!--$heading = $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath('//div[contains(@class, \'inline-wysiwyg\')]//h2'));-->
105-
<!--$text = $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::xpath('//div[contains(@class, \'inline-wysiwyg\')]//p[2]'));-->
106-
<!--$actions = new \Facebook\WebDriver\Interactions\WebDriverActions($webdriver);-->
107-
<!--$actions->moveToElement($heading, {{TinyMCEPartialHeadingSelection.startX}}, {{TinyMCEPartialHeadingSelection.startY}})-->
108-
<!-- ->clickAndHold()-->
109-
<!-- ->moveToElement($text, {{TinyMCEPartialTextSelection.endX}}, {{TinyMCEPartialTextSelection.endY}})-->
110-
<!-- ->release()-->
111-
<!-- ->perform();-->
112-
<!--}" stepKey="selectHeadingTextAndVariableTinyMCE"/>-->
97+
<helper class="\Magento\User\Test\Mftf\Helper\SelectText" method="selectHeadingTextAndVariableTinyMCE" stepKey="selectHeadingTextAndVariableTinyMCE">
98+
<argument name="firstContext">//div[contains(@class, 'inline-wysiwyg')]//h[2]</argument>
99+
<argument name="secondContext">//div[contains(@class, 'inline-wysiwyg')]//p[2]</argument>
100+
<argument name="startX">{{TinyMCEPartialHeadingSelection.startX}}</argument>
101+
<argument name="startY">{{TinyMCEPartialHeadingSelection.startY}}</argument>
102+
<argument name="endX">{{TinyMCEPartialTextSelection.endX}}</argument>
103+
<argument name="endY">{{TinyMCEPartialTextSelection.endY}}</argument>
104+
</helper>
105+
113106
<actionGroup ref="waitForTinyMCEInFocus" stepKey="waitForTinyMCEInFocus3"/>
114107
<actionGroup ref="assertSelectedText" stepKey="assertSelection3">
115108
<argument name="expectedSelectedText" value="TinyMCEHeadingVariableTextSelection"/>

0 commit comments

Comments
 (0)