Class: LegoTechSelenium::Driver

Inherits:
Object
  • Object
show all
Defined in:
lib/ui/driver/Driver.rb

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ Driver

Pass in an instance of the driver

Parameters:

  • The

    driver from Selenium Webdriver class



8
9
10
11
# File 'lib/ui/driver/Driver.rb', line 8

def initialize(driver)
  @driver = driver
  @wait = Selenium::WebDriver::Wait.new(:timeout => 15)
end

Instance Method Details

#get_selenium_driverSelenium::WebDriver

Function used to get the Selenium WebDriver

Returns:

  • (Selenium::WebDriver)

    Selenium webdriver



51
52
53
# File 'lib/ui/driver/Driver.rb', line 51

def get_selenium_driver
  @driver
end

#get_waitSelenium::WebDriver::Wait

Function used to get the wait object

Returns:

  • (Selenium::WebDriver::Wait)

    Wait object that does a wait for the object to appear in the DOM



45
46
47
# File 'lib/ui/driver/Driver.rb', line 45

def get_wait
  @wait
end

#set_element_find_wait(wait_time) ⇒ Object

Function used to override the overall wait in order to find an element within the DOM

Parameters:

  • wait_time (Number)

    represents how long to wait until an error is thrown



39
40
41
# File 'lib/ui/driver/Driver.rb', line 39

def set_element_find_wait(wait_time)
  @wait = Selenium::WebDriver::Wait.new(:timeout => wait_time)
end

#set_implicit_wait(implicit_wait) ⇒ Object

Set the amount of time the driver should wait when searching for elements.

Parameters:

  • implicit_wait

    seconds for implicit wait



15
16
17
# File 'lib/ui/driver/Driver.rb', line 15

def set_implicit_wait(implicit_wait)
  @driver.manage.timeouts.implicit_wait = implicit_wait
end

#set_navigate_to(navigate_to) ⇒ Object

The URL to navigate to

Parameters:

  • navigate_to

    location for the browser to navigate to



33
34
35
# File 'lib/ui/driver/Driver.rb', line 33

def set_navigate_to(navigate_to)
  @driver.navigate.to(navigate_to)
end

#set_page_load(page_load) ⇒ Object

Sets the amount of time to wait for a page load to complete before throwing an error.

Parameters:

  • page_load

    seconds to wait for page to load



21
22
23
# File 'lib/ui/driver/Driver.rb', line 21

def set_page_load(page_load)
  @driver.manage.timeouts.page_load = page_load
end

#set_script_timeout(script_timeout) ⇒ Object

Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.

Parameters:

  • script_time

    seconds to wait for script to complete



27
28
29
# File 'lib/ui/driver/Driver.rb', line 27

def set_script_timeout(script_timeout)
  @driver.manage.timeouts.script_timeout = script_timeout
end