Module: WatirPageHelper::Commands
- Defined in:
- lib/watir-page-helper/commands.rb
Instance Method Summary collapse
Instance Method Details
#classify(s) ⇒ Object
31 32 33 |
# File 'lib/watir-page-helper/commands.rb', line 31 def classify s s.to_s.split('_').map(&:capitalize).join end |
#on(*args) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/watir-page-helper/commands.rb', line 47 def on *args page_class(*args).tap do |p| p.expected_element if p.respond_to? :expected_element p.has_expected_title? if p.respond_to? :has_expected_title? yield p if block_given? end end |
#page_class(*args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/watir-page-helper/commands.rb', line 35 def page_class *args return args.first.new WatirPageHelper.browser if args.first.is_a? Class page = WatirPageHelper::Page.new WatirPageHelper.browser require "watir-page-helper/pages/#{args.join '/'}" mod = WatirPageHelper args.each do |name| mod = mod.const_get classify name end page.extend mod page end |
#visit(*args) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/watir-page-helper/commands.rb', line 55 def visit *args page_class(*args).tap do |p| p.goto p.expected_element if p.respond_to? :expected_element p.has_expected_title? if p.respond_to? :has_expected_title? yield p if block_given? end end |