Skip to content

Commit 962ea9c

Browse files
committed
- I made the "returnVariable" required for the "grab*" methods since it doesn't make sense to grab something and not store it.
- Adding additional case statements to support variables in a few unusual methods.
1 parent ee6d409 commit 962ea9c

File tree

2 files changed

+111
-57
lines changed

2 files changed

+111
-57
lines changed

src/Magento/AcceptanceTestFramework/Test/etc/testSchema.xsd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@
602602
<xs:extension base="xs:string">
603603
<xs:attribute type="xs:string" name="selector"/>
604604
<xs:attribute type="xs:string" name="userInput"/>
605+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
605606
<xs:attribute type="xs:string" name="variable"/>
606607
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
607608
<xs:attribute type="xs:boolean" name="remove" default="false"/>
@@ -615,7 +616,7 @@
615616
<xs:extension base="xs:string">
616617
<xs:attribute type="xs:string" name="userInput"/>
617618
<xs:attribute type="xs:string" name="parameterArray"/>
618-
<xs:attribute type="xs:string" name="returnVariable"/>
619+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
619620
<xs:attribute type="xs:string" name="variable"/>
620621
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
621622
<xs:attribute type="xs:boolean" name="remove" default="false"/>
@@ -628,7 +629,7 @@
628629
<xs:simpleContent>
629630
<xs:extension base="xs:string">
630631
<xs:attribute type="xs:string" name="url"/>
631-
<xs:attribute type="xs:string" name="returnVariable"/>
632+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
632633
<xs:attribute type="xs:string" name="variable"/>
633634
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
634635
<xs:attribute type="xs:boolean" name="remove" default="false"/>
@@ -642,7 +643,7 @@
642643
<xs:extension base="xs:string">
643644
<xs:attribute type="xs:string" name="selector"/>
644645
<xs:attribute type="xs:string" name="userInput"/>
645-
<xs:attribute type="xs:string" name="returnVariable"/>
646+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
646647
<xs:attribute type="xs:string" name="variable"/>
647648
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
648649
<xs:attribute type="xs:boolean" name="remove" default="false"/>
@@ -654,7 +655,7 @@
654655
<xs:complexType name="grabPageSourceType">
655656
<xs:simpleContent>
656657
<xs:extension base="xs:string">
657-
<xs:attribute type="xs:string" name="returnVariable"/>
658+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
658659
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
659660
<xs:attribute type="xs:boolean" name="remove" default="false"/>
660661
<xs:attribute type="xs:string" name="before"/>
@@ -666,7 +667,7 @@
666667
<xs:simpleContent>
667668
<xs:extension base="xs:string">
668669
<xs:attribute type="xs:string" name="selector"/>
669-
<xs:attribute type="xs:string" name="returnVariable"/>
670+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
670671
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
671672
<xs:attribute type="xs:boolean" name="remove" default="false"/>
672673
<xs:attribute type="xs:string" name="before"/>
@@ -679,7 +680,7 @@
679680
<xs:extension base="xs:string">
680681
<xs:attribute type="xs:string" name="selector"/>
681682
<xs:attribute type="xs:string" name="selectorArray"/>
682-
<xs:attribute type="xs:string" name="returnVariable"/>
683+
<xs:attribute type="xs:string" name="returnVariable" use="required"/>
683684
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
684685
<xs:attribute type="xs:boolean" name="remove" default="false"/>
685686
<xs:attribute type="xs:string" name="before"/>
@@ -1163,7 +1164,6 @@
11631164
<xs:extension base="xs:string">
11641165
<xs:attribute type="xs:string" name="userInput"/>
11651166
<xs:attribute type="xs:string" name="parameterArray"/>
1166-
<xs:attribute type="xs:string" name="variable"/>
11671167
<xs:attribute type="xs:string" name="value"/>
11681168
<xs:attribute type="xs:string" name="mergeKey" use="required"/>
11691169
<xs:attribute type="xs:boolean" name="remove" default="false"/>

src/Magento/AcceptanceTestFramework/Util/TestGenerator.php

Lines changed: 104 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
302302
$returnVariable = $customActionAttributes['returnVariable'];
303303
}
304304

305-
if (isset($customActionAttributes['url']) && isset($customActionAttributes['userInput'])) {
305+
if (isset($customActionAttributes['variable'])) {
306+
$input = sprintf("$%s", $customActionAttributes['variable']);
307+
} elseif (isset($customActionAttributes['url']) && isset($customActionAttributes['userInput'])) {
306308
$input = sprintf("\"%s\"", $customActionAttributes['userInput']);
307309
} elseif (isset($customActionAttributes['userInput'])) {
308310
$input = sprintf("\"%s\"", $customActionAttributes['userInput']);
@@ -354,6 +356,12 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
354356
case "amOnUrl":
355357
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
356358
break;
359+
case "appendField":
360+
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $input);
361+
break;
362+
case "attachFile":
363+
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $input);
364+
break;
357365
case "click":
358366
if ($input && $selector) {
359367
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $input, $selector);
@@ -463,6 +471,12 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
463471
case "dontSeeInFormFields":
464472
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $parameterArray);
465473
break;
474+
case "dontSeeInTitle":
475+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
476+
break;
477+
case "dontSeeInPageSource":
478+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
479+
break;
466480
case "dontSeeInSource":
467481
// TODO: Solve the HTML parsing issue.
468482
$testSteps .= sprintf("\t\t$%s->%s(\"%s\");\n", $actor, $actionName, $html);
@@ -480,6 +494,9 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
480494
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
481495
}
482496
break;
497+
case "dontSeeOptionIsSelected":
498+
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $input);
499+
break;
483500
case "dragAndDrop":
484501
$testSteps .= sprintf(
485502
"\t\t$%s->%s(\"%s\", \"%s\");\n",
@@ -503,7 +520,7 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
503520
$testSteps .= sprintf(
504521
"\t\t$%s->%s(%s, \"%s\");\n",
505522
$actor,
506-
actionName,
523+
$actionName,
507524
$input,
508525
$customActionAttributes['locale']
509526
);
@@ -512,58 +529,46 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
512529
}
513530
break;
514531
case "grabCookie":
515-
if (isset($returnVariable)) {
516-
if (isset($parameterArray)) {
517-
$testSteps .= sprintf(
518-
"\t\t$%s = $%s->%s(%s, %s);\n",
519-
$returnVariable,
520-
$actor,
521-
$actionName,
522-
$input,
523-
$parameterArray
524-
);
525-
} else {
526-
$testSteps .= sprintf(
527-
"\t\t$%s = $%s->%s(%s);\n",
528-
$returnVariable,
529-
$actor,
530-
$actionName,
531-
$input
532-
);
533-
}
532+
if (isset($parameterArray)) {
533+
$testSteps .= sprintf(
534+
"\t\t$%s = $%s->%s(%s, %s);\n",
535+
$returnVariable,
536+
$actor,
537+
$actionName,
538+
$input,
539+
$parameterArray
540+
);
534541
} else {
535-
if (isset($parameterArray)) {
536-
$testSteps .= sprintf(
537-
"\t\t$%s->%s(%s, %s);\n",
538-
$actor,
539-
$actionName,
540-
$input,
541-
$parameterArray
542-
);
543-
} else {
544-
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
545-
}
542+
$testSteps .= sprintf(
543+
"\t\t$%s = $%s->%s(%s);\n",
544+
$returnVariable,
545+
$actor,
546+
$actionName,
547+
$input
548+
);
546549
}
547550
break;
551+
case "grabAttributeFrom":
552+
$testSteps .= sprintf("\t\t$%s = $%s->%s(%s, %s);\n", $returnVariable, $actor, $actionName, $selector, $input);
553+
break;
548554
case "grabFromCurrentUrl":
549-
if (isset($returnVariable)) {
550-
if ($input) {
551-
$testSteps .= sprintf(
552-
"\t\t$%s = $%s->%s(%s);\n",
553-
$returnVariable,
554-
$actor,
555-
$actionName,
556-
$input
557-
);
558-
} else {
559-
$testSteps .= sprintf("\t\t$%s = $%s->%s();\n", $returnVariable, $actor, $actionName);
560-
}
555+
if ($input) {
556+
$testSteps .= sprintf(
557+
"\t\t$%s = $%s->%s(%s);\n",
558+
$returnVariable,
559+
$actor,
560+
$actionName,
561+
$input
562+
);
561563
} else {
562-
if ($input) {
563-
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
564-
} else {
565-
$testSteps .= sprintf("\t\t$%s->%s();\n", $actor, $actionName);
566-
}
564+
$testSteps .= sprintf("\t\t$%s = $%s->%s();\n", $returnVariable, $actor, $actionName);
565+
}
566+
break;
567+
case "grabMultiple":
568+
if ($input) {
569+
$testSteps .= sprintf("\t\t$%s = $%s->%s(%s, %s);\n", $returnVariable, $actor, $actionName, $selector, $input);
570+
} else {
571+
$testSteps .= sprintf("\t\t$%s = $%s->%s(%s);\n", $returnVariable, $actor, $actionName, $selector);
567572
}
568573
break;
569574
case "grabValueFrom":
@@ -579,6 +584,9 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
579584
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $selector);
580585
}
581586
break;
587+
case "loadSessionSnapshot":
588+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
589+
break;
582590
case "loginAsAdmin":
583591
if (isset($customActionAttributes['username']) && isset($customActionAttributes['password'])) {
584592
$testSteps .= sprintf(
@@ -648,6 +656,9 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
648656
$customActionAttributes['height']
649657
);
650658
break;
659+
case "saveSessionSnapshot":
660+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
661+
break;
651662
case "scrollTo":
652663
$testSteps .= sprintf("\t\t$%s->%s(%s, %s, %s);\n", $actor, $actionName, $selector, $x, $y);
653664
break;
@@ -729,9 +740,15 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
729740
case "seeInPageSource":
730741
// TODO: Solve the HTML parsing issue.
731742
break;
743+
case "seeInPopup":
744+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
745+
break;
732746
case "seeInSource":
733747
// TODO: Solve the HTML parsing issue.
734748
break;
749+
case "seeInTitle":
750+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
751+
break;
735752
case "seeLink":
736753
if (isset($step['url'])) {
737754
$testSteps .= sprintf(
@@ -751,9 +768,12 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
751768
$actor,
752769
$actionName,
753770
$selector,
754-
$customActionAttributes['userInput']
771+
$input
755772
);
756773
break;
774+
case "seeOptionIsSelected":
775+
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $input);
776+
break;
757777
case "selectOption":
758778
if ($parameterArray) {
759779
$testSteps .= sprintf(
@@ -807,6 +827,40 @@ private function generateStepsPhp($stepsObject, $hookObject = false)
807827
);
808828
}
809829
break;
830+
case "switchToIFrame":
831+
if ($input) {
832+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
833+
} else {
834+
$testSteps .= sprintf("\t\t$%s->%s();\n", $actor, $actionName);
835+
}
836+
break;
837+
case "switchToPreviousTab":
838+
if ($input) {
839+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
840+
} else {
841+
$testSteps .= sprintf("\t\t$%s->%s();\n", $actor, $actionName);
842+
}
843+
break;
844+
case "switchToNextTab":
845+
if ($input) {
846+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
847+
} else {
848+
$testSteps .= sprintf("\t\t$%s->%s();\n", $actor, $actionName);
849+
}
850+
break;
851+
case "switchToWindow":
852+
if ($input) {
853+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
854+
} else {
855+
$testSteps .= sprintf("\t\t$%s->%s();\n", $actor, $actionName);
856+
}
857+
break;
858+
case "typeInPopup":
859+
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $input);
860+
break;
861+
case "unselectOption":
862+
$testSteps .= sprintf("\t\t$%s->%s(%s, %s);\n", $actor, $actionName, $selector, $input);
863+
break;
810864
case "wait":
811865
$testSteps .= sprintf("\t\t$%s->%s(%s);\n", $actor, $actionName, $time);
812866
break;

0 commit comments

Comments
 (0)