Method: PageObject::Accessors#expected_element

Defined in:
lib/page-object/accessors.rb

#expected_element(element_name, timeout = 5) ⇒ boolean

Creates a method that provides a way to initialize a page based upon an expected element. This is useful for pages that load dynamic content.

Examples:

Specify a text box named :address expected on the page within 10 seconds

expected_element(:address, 10)
page.has_expected_element?

Parameters:

  • the (Symbol)

    name given to the element in the declaration

  • timeout (optional, Integer) (defaults to: 5)

    default value is 5 seconds

Returns:

  • (boolean)


54
55
56
57
58
# File 'lib/page-object/accessors.rb', line 54

def expected_element(element_name, timeout=5)
  define_method("has_expected_element?") do
    self.respond_to? "#{element_name}_element" and self.send("#{element_name}_element").when_present timeout
  end
end