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; }");

7 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.
    Selenium

    ReplyDelete
  5. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in



    selenium training in Bangalore
    selenium training in Marathahalli
    selenium training in Btm layout
    selenium training in Jaya nagar
    selenium training in Electronic city
    selenium training in Kalyan nagar

    ReplyDelete