How to convert WebElement into html string ?

1,216 views
Skip to first unread message

Joeyjoey

unread,
Dec 1, 2010, 5:01:57 PM12/1/10
to webdriver
I would like to know how I can convert my WebElement element, into an
html string representation.

I would then like to parse this string into a standard Java xpath
library.

The FireFoxDriver's xpath has some limitations, so I am choosing this
approach.

Simon Stewart

unread,
Dec 2, 2010, 7:13:26 AM12/2/10
to webd...@googlegroups.com
Use the JavascriptExecutor to get the innerHTML of the element:

((JavascriptExecutor) driver).executeScript(
"return arguments[0].innerHTML", element);

Simon

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> 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