Hi all,
Here I am going to list out ways to handle iFrames parts in selenium automation as I read from some sites.
Example-1:
Example-2:
Here I am going to list out ways to handle iFrames parts in selenium automation as I read from some sites.
Example-1:
- //Gmail Body is an iframe. Here we are writing content to body of new mail in selenium
- var bodytext="Sample Body Text for Testing";
- var iframe_locator = "css=table:contains('Subject:') +* iframe\";
- var iframe_body = selenium.browserbot.findElement(iframe_locator).contentWindow.document.body;
- if (browserVersion.isChrome) {
- iframe_body.textContent=bodytext;
- } else if(browserVersion.isIE) {
- iframe_body.innerText=bodytext;
- }
Example-2:
- //Switch to the frame - use index/name
- driver.switchTo().frame("frameName");
- //Also you can use like
SwitchTo.Frame(relative=up)
SwitchTo.Frame(relative=top)
// Do your operations in frame - //Switch back to the parent window
- driver.switchTo().defaultContent();
Comments
Post a Comment