Webdriver - Get Rich Text Editor Content

1,411 views
Skip to first unread message

Arun Kumaresan

unread,
Dec 6, 2011, 2:12:54 PM12/6/11
to Selenium Users
Hi,
I am trying to get the content from Rich Text Editor along with all
the formattings like bold, italic, font color etc.

But When I do a getText() of the iframe, I loose all the formatting
context. All I get is a plain text.

Is there a way to get the content from Rich Text Editor using all the
formatting ?

I am looking for something like getting the entire innerHTML.


Regards,
Arun Kumaresan

bis

unread,
Dec 6, 2011, 2:24:13 PM12/6/11
to seleniu...@googlegroups.com
what editor are you running your tests against? some of them have a tab or a button to view source which usually has the text there with all the html tags. I have never had to mess around with a RTE but i would imagine that would be the easiest way

Arun Kumaresan

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Arun Kumaresan

unread,
Dec 6, 2011, 3:23:31 PM12/6/11
to seleniu...@googlegroups.com
I am running tests against Dojo Editor (This is a rich text editor that comes out of the box with dojo).

--
Regards,
Arun Kumaresan

bis

unread,
Dec 6, 2011, 3:38:34 PM12/6/11
to seleniu...@googlegroups.com
looks like this is the html for it
<div class="dijitEditorIFrameContainer">
<iframe id="dijit_Editor_0_iframe" class="dijitEditorIFrame" frameborder="0" style="border: medium none; width: 100%;" src="javascript:parent.dijit.byId("dijit_Editor_0")._iframeSrc">
<html>
<head>
<meta content="text/html" http-equiv="Content-Type">
<style>
</head>
<body id="dijitEditorBody" style="color: rgb(51, 51, 51);" onload="frameElement._loadFunc(window,document)">
<ul>
<li>
Lorem
<a _djrealurl="http://dojotoolkit.org" href="http://dojotoolkit.org">and a link</a>
, what do you think?
</li>
<li>This is the Editor with a Toolbar attached.</li>
</ul>
<p _moz_dirty="">
</body>
</html>
</iframe>

using this http://dojotoolkit.org/widgets and going to the rte tag so looks pretty straight forward switching to that iframe and pulling out the info you need then pulling out

seems like it adds a span when you add new items to the editor
<span _moz_dirty="" style="font-weight: bold;">This is new</span>
<br _moz_dirty="">

Arun Kumaresan

unread,
Dec 7, 2011, 1:47:02 PM12/7/11
to seleniu...@googlegroups.com
That is almost what I have in the UI I am testing. and as you said, it adds span _moz_dirty with every formatting option.
Now how do I get the text with the formatting using webdriver.
 
driver.switchTo().frame(<FrameId>);
targetElement = driver.findElement(By.tagName("body"));
With the above code, I just get the plain text without the formatting Like bold/italic etc..
How do get the value with the formatting tags.
 
Regards,
Arun Kumaresan.

Arun Kumaresan

unread,
Dec 7, 2011, 1:48:21 PM12/7/11
to seleniu...@googlegroups.com
Correction in the lines below
 
driver.switchTo().frame(<FrameId>);
targetElement = driver.findElement(By.tagName("body"));
targetElement.getText();

--
Regards,
Arun Kumaresan
Reply all
Reply to author
Forward
0 new messages