Ekin,

I use monkey patching of Watir that works:

        require 'watir'

# == "Monkey patch" Watir for better compatibility with Watir-WebDriver ==

        require 'watir/element_collections'
        Watir::ElementCollections.class_eval do
          alias_method :original_array_op, :[]

          # Zero-based array operator
          def [](n)
            return original_array_op(n+1)
          end
        end

        require 'watir/container'
        require 'watir/element'
        require 'watir/table'
        Watir::TableRow.class_eval do
          alias_method :original_array_op, :[]

          # Zero-based array operator
          def [](n)
            return original_array_op(n+1)
          end
        end

You can add new methods in the same manner.

I ran into interesting issues when I tried to do it initially. Here is the StackOverflow discussion on why additional require-s are needed: http://stackoverflow.com/questions/4893923/weird-problems-with-reopening-ruby-classes

--
DK
AIM: DKroot1, Skype: DKroot


On 4/13/11 4:19 AM, Ekin Han wrote:
Hi all,

Rencently I found that I will add some methods to Watir::Table class.So i wrote some codes like following:

module Watir
  class Table
    def the_method_i_want_to_add
      #somthing
    end
  end
end

I saved these codes in a file and during the runtime i required this file.

But it does not work, some errors like 'undifined mehod autoit for Watir module...' occured.

How can I add some methods to the Table class without modify the source code? I just want to add the method during the runtime.
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

--
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to