Class: Capybara::Wheel::Page
- Inherits:
-
Object
- Object
- Capybara::Wheel::Page
- Extended by:
- Includes::ClassIncludes
- Includes:
- Includes
- Defined in:
- lib/capybara/wheel/page.rb
Class Method Summary collapse
Instance Method Summary collapse
- #has_title?(expected_title) ⇒ Boolean
-
#on {|_self| ... } ⇒ Object
execute a block in the context of this page.
-
#on_page? ⇒ Boolean
Return true if the browser is on this page.
-
#path ⇒ Object
Returns the path (relative URI) of this page.
-
#visit(&block) ⇒ Object
actively visits page and executes block in context.
Methods included from Includes::ClassIncludes
Methods included from Includes
Class Method Details
.element(name, selector, options = {}, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capybara/wheel/page.rb', line 44 def self.element(name, selector, = {}, &block) begin element_klass = const_set("#{name}", Capybara::Wheel::ElementFactory.create_element_klass(selector, , 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 |
Instance Method Details
#has_title?(expected_title) ⇒ Boolean
40 41 42 |
# File 'lib/capybara/wheel/page.rb', line 40 def has_title?(expected_title) .has_css?("head title", text: expected_title) end |
#on {|_self| ... } ⇒ Object
execute a block in the context of this page
22 23 24 25 26 27 28 |
# 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? ⇒ Boolean
Return true if the browser is on this page
36 37 38 |
# File 'lib/capybara/wheel/page.rb', line 36 def on_page? raise NotImplementedError, "implement me, e.g. using #has_title?" end |
#path ⇒ Object
Returns the path (relative URI) of this page
31 32 33 |
# File 'lib/capybara/wheel/page.rb', line 31 def path raise NotImplementedError, "implement to support page.visit" end |
#visit(&block) ⇒ Object
actively visits page and executes block in context
11 12 13 14 15 16 17 18 19 |
# File 'lib/capybara/wheel/page.rb', line 11 def visit(&block) .visit(path) if block_given? on(&block) else on_page? end return self end |