Željko Filipin's Blog on Software and Testing

Test like you do not need the money.

Extend Watir

with 2 comments

p6210022.JPG

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

Written by Željko Filipin

July 4th, 2007 at 11:42 am

Posted in Watir

Tagged with

2 Responses to 'Extend Watir'

Subscribe to comments with RSS or TrackBack to 'Extend Watir'.

  1. Željko,

    Is it possible to overload the method so if we do not specify the parameter ‘how’, the method will try to use :id and :name.

    So we could use the method:

    ie.h4(“addproject”).click

    This is how InCisif.net works.

    Thanks.

    Frederic Torres

    5 Jul 07 at 2:18 am

  2. Frederic,

    It would be the best to post your question at Watir forum. This is the link to this thread. http://forums.openqa.org/thread.jspa?threadID=8972&tstart=0

Leave a Reply