cheezy / page-object

Gem to implement PageObject pattern in watir-webdriver and selenium-webdriver
MIT License
653 stars 220 forks source link

method_missing should only delegate available methods #492

Closed jkotests closed 4 years ago

jkotests commented 4 years ago

When a method does not exist, we get the errors:

     NoMethodError:
       undefined method `asdfasdfad' for #<Watir::Browser:0x060d06b0>
     # scratch_page_object.rb:35:in `block (2 levels) in <main>'

     NoMethodError:
       undefined method `asdfdsafasdf' for #<Watir::Div: located: false; {:id=>"asdf", :tag_name=>"div"}>
     # scratch_page_object.rb:43:in `block (2 levels) in <main>'

The underlying Watir objects should be transparent. We should only delegate methods that exist - ie the error should be:

     NoMethodError:
       undefined method `asdfasdfad' for #<MyPage:0x06074a78>
     # ./page-object/lib/page-object.rb:52:in `method_missing'
     # scratch_page_object.rb:35:in `block (2 levels) in <main>'

     NoMethodError:
       undefined method `asdfdsafasdf' for #<PageObject::Elements::Div:0x06408a50>
     # ./page-object/lib/page-object/elements/element.rb:182:in `method_missing'
     # scratch_page_object.rb:43:in `block (2 levels) in <main>'