Skip to content

Commit 1ec77cf

Browse files
Merge pull request #433 from magento-pangolin/MQE-1994
MQE-1994: Refactor MFTF tests/actionGroups that need custom actions
2 parents 234c4c7 + 86b2a68 commit 1ec77cf

File tree

2 files changed

+102
-30
lines changed

2 files changed

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

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\PageBuilder\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\PageBuilder\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\PageBuilder\Test\Mftf\Helper\SelectText" method="selectHeadingTextAndVariableTinyMCE" stepKey="selectHeadingTextAndVariableTinyMCE">
98+
<argument name="firstContext">//div[contains(@class, 'inline-wysiwyg')]//h2</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)