class Capybara::Wheel::Page
Public Class Methods
element(name, selector, options = {}, &block)
click to toggle source
# File lib/capybara/wheel/page.rb, line 44 def self.element(name, selector, options = {}, &block) begin element_klass = const_set("#{name}", Capybara::Wheel::ElementFactory.create_element_klass(selector, options, block)) rescue NameError puts "We recommend using capitalized element and subelement names" name = name.capitalize! retry end define_method(underscore(name).to_sym) { element_klass.new(selector) } self end
Public Instance Methods
has_title?(expected_title)
click to toggle source
# File lib/capybara/wheel/page.rb, line 40 def has_title?(expected_title) capybara.has_css?("head title", text: expected_title) end
on() { |self| ... }
click to toggle source
execute a block in the context of this page
# File lib/capybara/wheel/page.rb, line 22 def on unless on_page? raise "We don't appear to be on the #{self.class}" end yield self if block_given? self end
on_page?()
click to toggle source
Return true if the browser is on this page
# File lib/capybara/wheel/page.rb, line 36 def on_page? raise NotImplementedError, "implement me, e.g. using #has_title?" end
path()
click to toggle source
Returns the path (relative URI) of this page
# File lib/capybara/wheel/page.rb, line 31 def path raise NotImplementedError, "implement to support page.visit" end
visit(&block)
click to toggle source
actively visits page and executes block in context
# File lib/capybara/wheel/page.rb, line 11 def visit(&block) capybara.visit(path) if block_given? on(&block) else on_page? end return self end