Not sure about Web Driver, but wonder why Selenium never had API method to get a subset of HTML, basically the innerHTML of a given element. Only offering to return the full HTML page source.
Perhaps because innerHTML is more of a developer used feature, probably not for testers who also happen to not have a web developer background?
But in any case, you can still get it via the DOM for Selenium RC.
html = selenium.getEval(“this.browserbot.findElement(\”id=someElementId\”).innerHTML”);
From a test execution performance standpoint, not sure if getting innerHTML is significantly slower than getting the page’s HTML source. But as an automator/developer, I’d rather not want to have to parse out the desired subset of HTML from the whole page source.
There is one benefit, for me anyways, to use innerHTML and that is to convert it to valid XML for further processing like traversal of the data via XML DOM via native code than via Selenium, which should be faster and more powerful to do in your native language than to do it via Selenium.
Thought I’d mention that for WebDriver, innerHTML DOM property is much easier to access. WebDriver treats it as an attribute of an element, so you can simply:
String elemHtml = driver.findElement(By.id(“someId”)).getAttribute(“innerHTML”);
You can then manipulate it as plain text, or convert & load as an XML DOM object.