Skip to content

Commit ff6d257

Browse files
authored
MQE-336: [Generator] Add support for Codeception "Locator" selectors
- Added locatorFunction attribute to elements and ElementObject - Changed ActionObject to look for selector, then locatorFunction when trying to resolve element references. - TestGenerator fixes to add double quotes to locatorFunction arguments, necessary for good output. - Verification test fixes and additions.
1 parent e041473 commit ff6d257

17 files changed

+244
-5
lines changed

dev/tests/verification/Resources/ActionGroupFunctionalCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/BasicFunctionalCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/DataReplacementCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_generated\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class LocatorFunctionCest
21+
{
22+
/**
23+
* @Parameter(name = "AcceptanceTester", value="$I")
24+
* @param AcceptanceTester $I
25+
* @return void
26+
*/
27+
public function LocatorFuctionTest(AcceptanceTester $I)
28+
{
29+
$I->amGoingTo("create entity that has the mergeKey: data");
30+
$ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson");
31+
$data = new DataPersistenceHandler($ReplacementPerson);
32+
$data->createEntity();
33+
$I->click(Locator::contains("'label'", "'Name'"));
34+
$I->click(Locator::contains("'label'", "'Name'"));
35+
$I->click(Locator::find("'img'", ['title' => 'diagram']));
36+
$I->click(Locator::contains("string", "'Name'"));
37+
$I->click(Locator::contains("John", "'Name'"));
38+
$I->click(Locator::contains($data->getCreatedDataByName('key') . "", "'Name'"));
39+
$I->click(Locator::contains("string1", "string2"));
40+
$I->click(Locator::contains("John", "Doe"));
41+
$I->click(Locator::contains($data->getCreatedDataByName('key1') . "", "" . $data->getCreatedDataByName('key2')));
42+
$I->click(Locator::contains("string1", "John"));
43+
$I->click(Locator::contains("string1", "" . $data->getCreatedDataByName('key1')));
44+
$I->click(Locator::contains("John", "" . $data->getCreatedDataByName('key1')));
45+
}
46+
}

dev/tests/verification/Resources/MergeFunctionalCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/PageReplacementCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/ParameterArrayCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/PersistedReplacementCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;

dev/tests/verification/Resources/SectionReplacementCest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Magento\FunctionalTestingFramework\AcceptanceTester;
55
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
66
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
77
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
89
use Yandex\Allure\Adapter\Annotation\Features;
910
use Yandex\Allure\Adapter\Annotation\Stories;
1011
use Yandex\Allure\Adapter\Annotation\Title;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
9+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<cest name="LocatorFunctionCest">
12+
<test name="LocatorFuctionTest">
13+
<createData entity="ReplacementPerson" mergeKey="data"/>
14+
15+
<click mergeKey="SimpleLocator" selector="{{LocatorFunctionSection.simpleLocator}}"/>
16+
<click mergeKey="SimpleLocatorNonShorthand" selector="{{LocatorFunctionSection.simpleLocatorNonShorthand}}"/>
17+
<click mergeKey="ArrayLocator" selector="{{LocatorFunctionSection.arrayLocator}}"/>
18+
19+
<click mergeKey="OneParamLiteral" selector="{{LocatorFunctionSection.simpleLocatorOneParam('string')}}"/>
20+
<click mergeKey="OneParamData" selector="{{LocatorFunctionSection.simpleLocatorOneParam(ReplacementPerson.firstname)}}"/>
21+
<click mergeKey="OneParamPersisted" selector="{{LocatorFunctionSection.simpleLocatorOneParam($data.key$)}}"/>
22+
23+
<click mergeKey="TwoParamLiteral" selector="{{LocatorFunctionSection.simpleLocatorTwoParam('string1', 'string2')}}"/>
24+
<click mergeKey="TwoParamData" selector="{{LocatorFunctionSection.simpleLocatorTwoParam(ReplacementPerson.firstname, ReplacementPerson.lastname)}}"/>
25+
<click mergeKey="TwoParamPersisted" selector="{{LocatorFunctionSection.simpleLocatorTwoParam($data.key1$, $data.key2$)}}"/>
26+
27+
<click mergeKey="TwoParamMix1" selector="{{LocatorFunctionSection.simpleLocatorTwoParam('string1', ReplacementPerson.firstname)}}"/>
28+
<click mergeKey="TwoParamMix2" selector="{{LocatorFunctionSection.simpleLocatorTwoParam('string1', $data.key1$)}}"/>
29+
<click mergeKey="TwoParamMix3" selector="{{LocatorFunctionSection.simpleLocatorTwoParam(ReplacementPerson.firstname, $data.key1$)}}"/>
30+
</test>
31+
</cest>
32+
</config>

0 commit comments

Comments
 (0)