-
-
Save TopherGopher/8446617 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
/** | |
* Sets an iFrame ID to no_name_iframe if there is no ID. You can then add a Switch to iFrame step after it using the na_name_iframe ID. | |
* | |
* @Given /^I the set the iframe located in element with an id of "([^"]*)"$/ | |
*/ | |
public function iSetTheIframeLocatedInElementWithAnIdOf($element_id) { | |
$element = $this->getMainContext()->getSession()->getPage()->findById($element_id); | |
if ($element == NULL) { | |
throw new \Exception(sprintf("Element with ID '%s' not found", $element_id)); | |
} | |
$javascript = <<<JS | |
(function(){ | |
var elem = document.getElementById('$element_id'); | |
var iframes = elem.getElementsByTagName('iframe'); | |
var f = iframes[0]; | |
f.id = "no_name_iframe"; | |
})() | |
JS; | |
$this->getMainContext()->getSession()->executeScript($javascript); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment