Filipin.eu

Željko Filipin's blog.
Home Blog Tags License

View on GitHub
4 July 2007

Extend Watir

by Željko Filipin

I had to click a h4 headline.

<h4 id="addproject">Create a new project</h4>

This did not work.

browser.h4(:id, "addproject").click

I posted a question to wtr-general mailing list and Bret Pettichord suggested to extend Watir with this, so it would support h4 headlines.

module Watir
  class H4 < NonControlElement
    TAG = 'H4'
  end
  module Container
    def h4(how, what)
      return H4.new(self, how, what)
    end
  end
end

Now this works.

browser.h4(:id, "addproject").click
tags: code - ruby