Pages

Search This Blog

Monday, September 27, 2010

How to write in Iframe in selenium

Selenium is unable to type in iframe. But we can write in it by identifying the iframe using css.
When you write any mail in gmail you can see the body is a iframe we can write in it using below commands
Selenium IDE



<tr>
 <td>storeEval</td>
 <td>var bodytext=" Writing text in iframe body with the help of http://automationtricks.blogspot.com ";  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; }</td>
 <td></td>
</tr>


Selenium RC.


String  = selenium.getEval("var bodytext=\" Writing text in iframe body with the help of http://automationtricks.blogspot.com \";  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; }");

8 comments:

  1. Sorry but this is not working in my case.It is sayin dat this element is not found.

    ReplyDelete
  2. sudhakar3.qa@gmail.comDecember 7, 2011 at 9:51 PM

    How to enter the text into richtext box?please suggest

    ReplyDelete
  3. Im trying to write css to assert element which is the whole frame

    verify the video image from youtube is present or not
    verify the text,url and the embedded content from the youtube are present or not

    how to write the css for above requitrment and for below code ????????????

    anyone help please.....................

    ReplyDelete
  4. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  5. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  6. It was very nice blog to learn about SAP HR.Thanks for sharing new things.SAP HR

    ReplyDelete
  7. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

    ReplyDelete