Class: MiniAutobot::PageObjects::Widgets::Base

Inherits:
Object
  • Object
show all
Extended by:
ElementContainer
Includes:
Utils::Castable, Utils::OverlayAndWidgetHelper, Utils::PageObjectHelper
Defined in:
lib/mini_autobot/page_objects/widgets/base.rb

Overview

A widget represents a portion (an element) of a page that is repeated or reproduced multiple times, either on the same page, or across multiple page objects or page modules.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ElementContainer

add_to_mapped_items, elements

Methods included from Utils::OverlayAndWidgetHelper

#get_overlay!, #get_widgets!

Methods included from Utils::PageObjectHelper

#connector_is_saucelabs?, #current_page, #is_element_present?, #is_element_present_and_displayed?, #json_save_to_ever_failed, #print_sauce_link, #put_value, #read_yml, #retry_with_count, #take_screenshot, #teardown, #update_sauce_session_name, #update_sauce_session_status, #wait_for_attribute_to_have_value, #wait_for_element_to_be_present, #wait_for_element_to_display, #with_url_change_wait

Methods included from Utils::Castable

#cast, #cast_any, included

Constructor Details

#initialize(page, element) ⇒ Base

Returns a new instance of Base.



16
17
18
19
20
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 16

def initialize(page, element)
  @driver = page.driver
  @page = page
  @element = element
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



14
15
16
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 14

def driver
  @driver
end

#elementObject (readonly)

Returns the value of attribute element.



14
15
16
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 14

def element
  @element
end

#pageObject (readonly)

Returns the value of attribute page.



14
15
16
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 14

def page
  @page
end

Instance Method Details

#find_all(how, what) ⇒ Object



31
32
33
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 31

def find_all(how, what)
  element.all(how, what)
end

#find_first(how, what) ⇒ Object



27
28
29
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 27

def find_first(how, what)
  element.find_element(how, what)
end

#page_objectObject

for widgets that include Utils::OverlayAndWidgetHelper



23
24
25
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 23

def page_object
  @page
end

#wait(opts = {}) ⇒ Object

Explicitly wait for a certain condition to be true:

wait.until { driver.find_element(:css, 'body.tmpl-srp') }

when timeout is not specified, default timeout 5 sec will be used when timeout is larger than 15, max timeout 15 sec will be used



39
40
41
42
43
44
45
46
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 39

def wait(opts = {})
  if !opts[:timeout].nil? && opts[:timeout] > 15
    puts "WARNING: #{opts[:timeout]} sec timeout is NOT supported by wait method,
        max timeout 15 sec will be used instead"
    opts[:timeout] = 15
  end
  Selenium::WebDriver::Wait.new(opts)
end