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

Inherits:
Object
  • Object
show all
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 Utils::OverlayAndWidgetHelper

#get_overlay!, #get_widgets!

Methods included from Utils::PageObjectHelper

#connector_is_saucelabs?, #is_element_present?, #is_element_present_and_displayed?, #json_save_to_ever_failed, #print_sauce_link, #put_value, #read_yml, #retry_with_count, #save_to_ever_failed, #take_screenshot, #teardown, #update_sauce_session

Methods included from Utils::Castable

#cast, #cast_any, included

Constructor Details

#initialize(page, element) ⇒ Base

Returns a new instance of Base.



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

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

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



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

def driver
  @driver
end

#elementObject (readonly)

Returns the value of attribute element.



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

def element
  @element
end

#pageObject (readonly)

Returns the value of attribute page.



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

def page
  @page
end

Instance Method Details

#page_objectObject

for widgets that include Utils::OverlayAndWidgetHelper



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

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



33
34
35
36
37
38
39
40
# File 'lib/mini_autobot/page_objects/widgets/base.rb', line 33

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