Created
January 11, 2014 00:57
-
-
Save alnutile/8365567 to your computer and use it in GitHub Desktop.
No name iframe
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) { | |
$check = 1; //@todo need to check using js if exists | |
if($check <= 0) { | |
throw new \Exception('Element not found'); | |
} else { | |
$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
Come up to this solution: