Parse HTML from database in Watir?

126 views
Skip to first unread message

Eachus Lonny

unread,
May 15, 2013, 10:03:22 PM5/15/13
to watir-...@googlegroups.com

This is a rather urgent issue.

I have some whole-page HTML in a database. I would like to get this HTML into Watir for parsing.

How can I tell Watir to load this HTML into the DOM?

I know I could write the data to a .html file and read it that way, but that would seem to be a rather roundabout way to do it.

How does one load HTML from text into Watir?


Lonny Eachus
===========



Alex Rodionov

unread,
May 16, 2013, 5:21:35 AM5/16/13
to watir-...@googlegroups.com
For the record, that was replied on IRC:

[09:25am] p0deje: lonny_: you can use data URI
[09:26am] p0deje: browser.goto "data:text/html,#{html}"
[09:27am] lonny_: Thanks. I'll give that a try.
[09:29am] lonny_: Yes! That worked. Thank you very much.

Chuck van der Linden

unread,
May 17, 2013, 1:41:32 PM5/17/13
to watir-...@googlegroups.com
Watir's specialty is driving browsers.. parsing HTML comes with that territory but neither Webdriver nor Watir are really optimized for html parsing.

Gems like Nokogiri on the other hand ARE designed for just that sort of thing.  IMHO if you are just trying to parse HTML, and not trying to drive a browser, you might be better off to just use Nokogiri (http://rubygems.org/gems/nokogiri

Željko Filipin

unread,
May 17, 2013, 1:43:32 PM5/17/13
to watir
On Fri, May 17, 2013 at 7:41 PM, Chuck van der Linden <cvande...@climate.com> wrote:
IMHO if you are just trying to parse HTML, and not trying to drive a browser, you might be better off to just use Nokogiri (http://rubygems.org/gems/nokogiri

+1

Željko

Lonny Eachus

unread,
Dec 2, 2013, 5:01:31 PM12/2/13
to watir-...@googlegroups.com

While in general that might be the case, my use-case requires Watir, and while Watir might not be great at parsing HTML,  using a completely separate parser like Nokigiri in ADDITION to Watir is overkill for this particular purpose.

Having said that, I would like to add: I must admit that I like the flexibility of Selenium-Webdriver, in that it can now drive many different browsers, and so on. However, Selenium-Webdriver also has some rather severe limitations, some of which were intentionally built in (I know that some limitations are by design, from my own conversations with Selenium-Webdriver developers.)

While the OLD (pre-FireWatir) Watir was restricted to IE, which was itself a severe limitation, if you could live with that it did many things better than the new Watir with Selenium-Webdriver does. I know Watir is a testing platform but it has many uses beyond testing that over the years have often been ignored or actively discouraged.

 
Reply all
Reply to author
Forward
0 new messages