0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Watir-Nokogiri is an HTML parser using Watir's API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Watir-Nokogiri

Watir-Nokogiri is an HTML parser using Watir's API.

Background

Watir (classic and webdriver) can have performance issues when parsing large HTML pages. One solution has been to extract the page's HTML using Watir and then parse the HTML with an HTML parser (ex Nokogiri). This required learning two APIs - Watir and the HTML parser. Watir-Nokogiri eliminates the need to learn an HTML parser API by applying the Watir API to the HTML parser Nokogiri.

Installation

gem install 'watir-nokogiri'

Usage

To use Watir-Nokogiri:

require 'watir-nokogiri'

Watir-Nokogiri can parse a string containing HTML.

This is typically supplied by a Watir browser:

doc = WatirNokogiri::Document.new(browser.html)

However, you can also read from a file:

doc = WatirNokogiri::Document.start('C:\some_file.html')

With the parsed document, you can use the standard Watir API to locate elements and validate text/attributes.

Check if an element exists

doc.div(:id => 'my_id').exists?

Get the text of an element

doc.span(:id => 'my_span').text

Get an attribute value of an element

doc.span(:id => 'my_span').attribute_value('name')

Count the number of elements

doc.text_fields.length