Issue 208 in robotframework-seleniumlibrary: Add keywords for working with inner HTML of an element

13 views
Skip to first unread message

robotframework-...@googlecode.com

unread,
Oct 16, 2011, 10:33:09 PM10/16/11
to robotframework-se...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Enhancement Priority-Medium

New issue 208 by manga...@gmail.com: Add keywords for working with inner
HTML of an element
http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=208

I may submit a patch with the requested enhancement later on, but in either
case, entering issue for tracking purposes and as FYI.

A common feature for websites and web apps these days is working with
innerHtml of an element via the DOM. Perhaps is a seldom used feature with
respect to Selenium test automation, but can be useful when there is a need
for it, particularly in cases of AJAX dynamic generation of DOM elements
and their HTML, where getting HTML page source may or may not have the
matching HTML subset.

Even if it did match, why grab all the bloated HTML when sometimes you just
need a subset.

Suggested keywords based on current library:

* keyword, arguments
* Get Inner Html, locator
* Log Inner Html, locator

Keyword can be implement with this type of code snippet that I've used in
another Selenium project.

return selenium.getEval("this.browserbot.findElement(\"" + locator
+ "\").innerHTML");

robotframework-...@googlecode.com

unread,
Oct 17, 2011, 1:27:37 AM10/17/11
to robotframework-se...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 208 by janne.t....@gmail.com: Add keywords for

This sounds reasonable (and trivial to implement)

robotframework-...@googlecode.com

unread,
Oct 19, 2011, 6:41:08 AM10/19/11
to robotframework-se...@googlegroups.com

Comment #2 on issue 208 by pekka.klarck: Add keywords for working with

1) Is innerHTML just an element attribute? If yes, isn't Get Element
Attribute enough instead of Get Inner HTML?

2) I don't think separate Log Inner HTML keyword is need anyway. We don't
have it for other elements or attributes either and you can very easily use
BuiltIn keyword Log for this purpose. The Log Source keyword is an
exception for the most common case.

robotframework-...@googlecode.com

unread,
Oct 19, 2011, 12:58:24 PM10/19/11
to robotframework-se...@googlegroups.com

Comment #3 on issue 208 by manga...@gmail.com: Add keywords for working

I will confirm with a test shortly, but innerHtml is a special DOM
attribute of all elements, which might not be able to extract with the
default Selenium's getAttribute() method. Hence my suggested code snippet.

Getting attributes is generally for items that are exposed in the element
itself in source code like:

<input id=val value="some value" style="" attributeName="someValue"/>

Where id, value, style, and attributeName are all valid attributes.
innerHtml is never defined within an element tag. It's a special attribute
that's only manipulated and accessed by javascript and CSS. I believe as a
Selenium user, you also have to use javascript like browserbot to access
such DOM attributes or properties.

robotframework-...@googlecode.com

unread,
Oct 24, 2011, 12:16:03 AM10/24/11
to robotframework-se...@googlegroups.com

Comment #4 on issue 208 by manga...@gmail.com: Add keywords for working

Verified trying to get the special DOM attribute with Get Element Attribute
fails.

FAIL ERROR: Could not find element attribute: id=promo-message@innerHTML

The following SeleniumLibrary command however works:

| ${html}= | Call Selenium Api | getEval |
this.browserbot.findElement('id=promo-message').innerHTML |

So we just need a keyword that will do that w/o user having to directly use
the Selenium API.

although the return value seemed to be a tuple for getEval, as returned by
Call Selenium Api:

${html} = OK,
<p><script>utmx_section("SMBHomePageTest")</script><a
href="/promo/tiny-prints-coupon-codes-promotions.htm"><strong>Save Big on
Holiday Cards! Enjoy Up to 20% Off Your Order</strong> | Code: OCTHO...

robotframework-...@googlecode.com

unread,
May 4, 2012, 6:06:20 AM5/4/12
to robotframework-se...@googlegroups.com
Updates:
Labels: Target-2.9

Comment #5 on issue 208 by pekka.klarck: Add keywords for working with
(No comment was entered for this change.)

robotframework-...@googlecode.com

unread,
May 4, 2012, 8:00:41 AM5/4/12
to robotframework-se...@googlegroups.com
Updates:
Status: Done
Owner: janne.t....@gmail.com

Comment #6 on issue 208 by robotfr...@gmail.com: Add keywords for
This issue was updated by revision 7b3c0f063258.

Reply all
Reply to author
Forward
0 new messages