How to write text in Body of an HTML page inserted in iFrame?

3,339 views
Skip to first unread message

Deepika

unread,
Sep 20, 2012, 7:20:37 AM9/20/12
to webd...@googlegroups.com
Hi All,

I am having a Rich Text Box in my application in which I need to write text. But I am not able to find its XPath,
Selenium IDE is also not recording  the stpe of writing text in this control.
Below is the HTML code of the same. please help me out. I have attached the screen shot also of that Control.


<div id="headMaster_cphMainChild_cphMain_txtDisclaimerText_designEditorArea" style="clear:both;padding-top:1px;">
<iframe id="headMaster_cphMainChild_cphMain_txtDisclaimerText_designEditor" class="headMaster_cphMainChild_cphMain_txtDisclaimerText_DesignBox" src="about:blank" style="padding: 0px; width:100%; height: 250px;">
<html>
<head>
</head>
<body>
Need to Insert Text Here
<br _moz_dirty="">
</body>

</html>
</iframe>
</div>

Thanks and regards,
Deepika
Inserttxt.jpg

Ben Thomas

unread,
Sep 20, 2012, 8:01:32 AM9/20/12
to webd...@googlegroups.com
give the frame a name and this should work, you have to tell your webdriver to switch to the frame

driver.switchTo().frame("Frame Name");

Deepika

unread,
Sep 20, 2012, 8:06:35 AM9/20/12
to webd...@googlegroups.com
Thanks Ben,

I did, but I need to write the text in the Body part of the HTML page which resided in this Frame.
Whcih means I have to use sendkeys command to write text. But I am not able to find such webElement.

 
Thanks and regards,
Deepika

Ben Thomas

unread,
Sep 20, 2012, 8:09:22 AM9/20/12
to webd...@googlegroups.com
I was just working on this same type of issue, the element was not found that was in the iframe but when I looked around online about iframes I see that you had to use that switchTo() command and then find the element and then use sendKeys to send it text. That is what worked for me

pratika

unread,
Sep 20, 2012, 8:28:28 AM9/20/12
to webd...@googlegroups.com
I am also facing the same problem afetr switching to correct iframe I am not able to find element inside that frame.

Dinesh s

unread,
Sep 20, 2012, 8:47:00 AM9/20/12
to webd...@googlegroups.com
Hi Deepika try  this code,may be it is useful for u..


driver.switchTo().frame("Frame Name");
driver.findElement(By.cssSelector("body")).sendKeys("your data");




Thanks
DineshS

Deepika

unread,
Sep 21, 2012, 4:34:37 AM9/21/12
to webd...@googlegroups.com
Thanka Dinesh,

It worked.  :)

Regards,
Deepika

Mike Riley

unread,
Sep 21, 2012, 12:57:01 PM9/21/12
to webd...@googlegroups.com
Deepika,

You are able to write something into the body where there was nothing?  That sounds like how ASP can replace what is in the text for an ASP label.  I was not aware you could do that.

Or did I misunderstand what you are doing?

Mike

Mark Collin

unread,
Sep 22, 2012, 4:16:05 AM9/22/12
to webd...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/j93SuwIDycsJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Reply all
Reply to author
Forward
0 new messages