-
-
Save flocondetoile/7a65cf708b5f96b68e7a144cf142139c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @When I switch to the frame by selector "[title=:arg1]" | |
*/ | |
public function switchToIFrameFromSelector($iframeSelector) { | |
$function = <<<JS | |
(function(){var iframe = document.querySelector("$iframeSelector");iframe.name = "iframeToSwitchTo";})() | |
JS; | |
try { | |
$this->getSession()->executeScript($function); | |
}catch (Exception $e){ | |
throw new \Exception("Element $iframeSelector was NOT found.".PHP_EOL . $e->getMessage()); | |
} | |
$this->getSession()->getDriver()->switchToIFrame("iframeToSwitchTo"); | |
} | |
/** | |
* @When /^(?:|I )fill in the iframe field with "(?P<value>(?:[^"]|\\")*)"$/ | |
*/ | |
public function iFillInTheIframeField($value) | |
{ | |
$this->spin(function (FeatureContext $context) use ($value) { | |
try { | |
$session = $this->getSession(); | |
$field = $this->getSession()->getPage()->find('xpath', '//input'); | |
if (!$field) { | |
throw new \Exception(sprintf('No input found on the page %s.', $session->getCurrentUrl())); | |
} | |
$field->setValue($value); | |
return TRUE; | |
} | |
catch (\Exception $e) { | |
return FALSE; | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Braintree | |
And I wait | |
When I switch to the frame "braintree-hosted-field-number" | |
Then I fill in the iframe field with "5555555555554444" | |
Then I switch out of all frames | |
When I switch to the frame "braintree-hosted-field-expirationMonth" | |
Then I fill in the iframe field with "03" | |
Then I switch out of all frames | |
When I switch to the frame "braintree-hosted-field-expirationYear" | |
Then I fill in the iframe field with "20" | |
Then I switch out of all frames | |
When I switch to the frame "braintree-hosted-field-cvv" | |
Then I fill in the iframe field with "123" | |
Then I switch out of all frames | |
# Back to Drupal | |
When I fill in the following: | |
| First name | Joseph | | |
| Last name | Schlitz | | |
| Street address | 2929 Browns Ln | | |
| City | Jonesboro | | |
| State | AR | | |
| Zip code | 72401 | | |
And I press "Continue to review" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment