featurist/coypu — pull request #72 by joshski (2013-10-24 16:14:49+00:00)
Title: inner and outer html element extensions

This PR helps when you need to turn a big DOM element into a complex object. For example, turning an HTML table into a list of objects, one for each row.

We tried this kind of thing:

browser.FindAllCss("tr").Select(tr =>
new Person {
Name = tr.FindCss("td.name").Text,
Age = tr.FindCss("td.age").Text
}
)

...but it was incredibly slow for big tables. It looked like the problem was that each call to "Text" triggered a browser round trip.

InnerHTML and OuterHTML give us the option of loading the whole table into, say, an XDocument where we can then use XPath to turn it into an object, in one hit.

I don't know whether it's appropriate to normalise the string result of these new methods, because different drivers return quite different innerHTML and outerHTML results for the same elements. For clarity I've left this normalisation to the consumer.