Skip to content

Commit

Permalink
Merge branch 'integration' into apf-311
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Gabhart committed Jun 9, 2021
2 parents ad4b7f4 + 425df49 commit 1e9b04f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Test/Mftf-23/ActionGroup/AmazonSwitchToPopupActionGroup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AmazonSwitchToPopupActionGroup">
<executeInSelenium function="function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {$webdriver->wait(30, 100)->until(\Facebook\WebDriver\WebDriverExpectedCondition::numberOfWindowsToBe(2));}" stepKey="allowPopupToOpen" />
<switchToNextTab stepKey="switchToPopup"/>
</actionGroup>
</actionGroups>
9 changes: 3 additions & 6 deletions Test/Mftf-23/Test/AmazonCancelReturnUrl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
<!--Save opener window name since popup auto-closes-->
<executeJS function="return window.name;" stepKey="openerName"/>
<click selector="{{AmazonLoginSection.login}}" stepKey="signInWithAmazon"/>
<wait time="1" stepKey="allowPopupToOpen"/>
<switchToNextTab stepKey="switchToWindowLoginPopup"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen" />

<!-- Login to Amazon -->
<actionGroup ref="AmazonBeginLoginOnlyActionGroup" stepKey="amazonBeginLoginOnlyActionGroup"/>
Expand All @@ -58,8 +57,7 @@
<!-- Click Amazon Pay button on product page and login -->
<click selector="{{AmazonButtonSection.product}}" stepKey="clickAmazonButton"/>

<wait time="1" stepKey="allowPopupToOpen2"/>
<switchToNextTab stepKey="switchToWindowLoginPopup2"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen2" />
<waitForElement selector="{{AmazonPageSection.checkoutButton}}" stepKey="seeAmazonCheckoutButton"/>

<!--Come back to checkout with default address-->
Expand All @@ -69,8 +67,7 @@

<!-- Click edit button on address -->
<click selector="{{AmazonCheckoutSection.editShippingButton}}" stepKey="clickAmazonEditShippingButton"/>
<wait time="1" stepKey="allowPopupToOpen3"/>
<switchToNextTab stepKey="switchToAddressEditPopup"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen3" />
<waitForElement selector="{{AmazonPageSection.cancelButton}}" stepKey="waitForCancelCheckout"/>

<!-- Click cancel button on Amazon hosted page -->
Expand Down
7 changes: 7 additions & 0 deletions Test/Mftf-24/ActionGroup/AmazonSwitchToPopupActionGroup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AmazonSwitchToPopupActionGroup">
<helper class="\Amazon\Pay\Test\Mftf\Helper\WaitForPopup" method="waitForPopup" stepKey="allowPopupToOpen" />
<switchToNextTab stepKey="switchToPopup"/>
</actionGroup>
</actionGroups>
24 changes: 24 additions & 0 deletions Test/Mftf-24/Helper/WaitForPopup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Amazon\Pay\Test\Mftf\Helper;

use Magento\FunctionalTestingFramework\Helper\Helper;

class WaitForPopup extends Helper {

public function waitForPopup() {
/** @var \Magento\FunctionalTestingFramework\Module\MagentoWebDriver $webDriver */
$webDriver = $this->getModule('\Magento\FunctionalTestingFramework\Module\MagentoWebDriver');

try {
$webDriver->executeInSelenium(function(\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
// Wait for up to 30 seconds, poll every 100ms
$webdriver->wait(30, 100)->until(\Facebook\WebDriver\WebDriverExpectedCondition::numberOfWindowsToBe(2));
});
} catch(\Exception $e) {
print($e);
}

}

}
9 changes: 3 additions & 6 deletions Test/Mftf-24/Test/AmazonCancelReturnUrl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
<!--Save opener window name since popup auto-closes-->
<executeJS function="return window.name;" stepKey="openerName"/>
<click selector="{{AmazonLoginSection.login}}" stepKey="signInWithAmazon"/>
<wait time="1" stepKey="allowPopupToOpen"/>
<switchToNextTab stepKey="switchToWindowLoginPopup"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen" />

<!-- Login to Amazon -->
<actionGroup ref="AmazonBeginLoginOnlyActionGroup" stepKey="amazonBeginLoginOnlyActionGroup"/>
Expand All @@ -58,8 +57,7 @@
<!-- Click Amazon Pay button on product page and login -->
<click selector="{{AmazonButtonSection.product}}" stepKey="clickAmazonButton"/>

<wait time="1" stepKey="allowPopupToOpen2"/>
<switchToNextTab stepKey="switchToWindowLoginPopup2"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen2" />
<waitForElement selector="{{AmazonPageSection.checkoutButton}}" stepKey="seeAmazonCheckoutButton"/>

<!--Come back to checkout with default address-->
Expand All @@ -69,8 +67,7 @@

<!-- Click edit button on address -->
<click selector="{{AmazonCheckoutSection.editShippingButton}}" stepKey="clickAmazonEditShippingButton"/>
<wait time="1" stepKey="allowPopupToOpen3"/>
<switchToNextTab stepKey="switchToAddressEditPopup"/>
<actionGroup ref="AmazonSwitchToPopupActionGroup" stepKey="allowPopupToOpen3" />
<waitForElement selector="{{AmazonPageSection.cancelButton}}" stepKey="waitForCancelCheckout"/>

<!-- Click cancel button on Amazon hosted page -->
Expand Down

0 comments on commit 1e9b04f

Please sign in to comment.