I remember similar problems during some experiments I was attempting a while back.
Another option is to simply reopen the browser class you want to extend, and start adding your own methods: class FireWatir::Firefox def your_custom_method .... Needless to say, if the Watir::IE / FireWatir::Firefox class and module structure ever changes, this code will break. How badly depends on how extensive the future changes are, I guess. :) But for what you are trying to do it might work. Also, one must be careful not to step on any methods that already exist. You can extend existing methods without much trouble, but the code gets a little more complicated (especially when extending class methods instead of instance methods). Some searches for info on Ruby "alias chaining" might help if you want to extend existing methods. Thanks Bill On Fri, Feb 12, 2010 at 12:16 PM, Brian Tomlin <tendonstren...@gmail.com>wrote: > Hello, > > In the past I have attempted to save some typing by extinding the IE > class so that I could create methods specific to my AUT, e.g.: > > require 'watir' > include Watir > > > class Salesforce < IE > def start > self.goto("http://test.salesforce.com") > end > > def login(username, password) > self.text_field(:name, "username").set(username) > self.text_field(:name, "password").set(password) > self.button(:id, "Login").click > end > end > > This always worked just fine for me, but now I am trying to do the > same exact thing with the Firefox class, > but when it executes the line "self.text_field(:name, > "username").set(username)", (called from a test script that is using a > "Salesforce" object as the browser) I get a runtime error: > > 1) Error: > test_start(TestLogin): > NoMethodError: undefined method `element_name' for #<Salesforce: > 0xb7209da8> > /var/lib/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb: > 276:in `locate_tagged_element' > /var/lib/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/ > input_element.rb:22:in `locate' > /var/lib/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb: > 964:in `exists?' > /var/lib/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/element.rb: > 905:in `assert_exists' > /var/lib/gems/1.8/gems/firewatir-1.6.5/lib/firewatir/elements/ > text_field.rb:149:in `set' > test_login.rb:17:in `test_start' > > > "self.goto" works fine but once I access those text fields it throws > an error. > > Am I doing something wrong, or is it just not possible to extend the > Firefox class is this way? > > Thanks, > Brian > > > -- > You received this message because you are subscribed to the Google Groups > "Watir General" group. > To post to this group, send email to watir-general@googlegroups.com > Before posting, please read the following guidelines: > http://wiki.openqa.org/display/WTR/Support > To unsubscribe from this group, send email to > watir-general+unsubscr...@googlegroups.com<watir-general%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/watir-general > -- You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general