Class: EDSL::PageObject::Page

Inherits:
ElementContainer
  • Object
show all
Extended by:
Visitable
Includes:
AJAX, Population
Defined in:
lib/edsl/page_object/page.rb

Overview

This class represents an entire page within the browser.

Using this base class is not a requirement, however code in some modules may assume that methods in this class are available when they’re dealing with pages

This allows your object to serve as a proxy for the browser and mirror it’s API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitable

page_url, params, params=

Methods included from AJAX

#wait_for_ajax

Methods included from Population

#fixture_fetch, fixture_fetcher, fixture_fetcher=, #populate, #populate_key, #populate_with

Constructor Details

#initialize(web_browser, visit = false) ⇒ Page

Create a new page.



22
23
24
25
26
# File 'lib/edsl/page_object/page.rb', line 22

def initialize(web_browser, visit = false)
  super(web_browser, nil)
  @page_ready_limit = DEFAULT_PAGE_READY_LIMIT
  goto if visit
end

Instance Attribute Details

#page_ready_limitObject

Returns the value of attribute page_ready_limit.



18
19
20
# File 'lib/edsl/page_object/page.rb', line 18

def page_ready_limit
  @page_ready_limit
end

Instance Method Details

#ready?Boolean

An always safe to call ready function. Subclasses should implement the _ready? method to provide an actual implementation.

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/edsl/page_object/page.rb', line 30

def ready?
  return _ready?
rescue
  return false
end

#when_ready(limit = nil) {|_self| ... } ⇒ Object

Block until the page is ready then yield / return self.

If a block is given the page will be yielded to it.

Yields:

  • (_self)

Yield Parameters:



40
41
42
43
44
45
46
47
48
# File 'lib/edsl/page_object/page.rb', line 40

def when_ready(limit = nil, &block)
  begin
    Watir::Wait.until(timeout: (limit || page_ready_limit)) { _ready? }
  rescue Timeout::Error
    raise Timeout::Error, "Timeout limit #{limit} reached waiting for #{self.class} to be ready"
  end
  yield self if block_given?
  self
end