Class: AutomationObject::Driver::AppiumAdapter::Element
- Inherits:
-
Proxy::Proxy
- Object
- Proxy::Proxy
- AutomationObject::Driver::AppiumAdapter::Element
- Includes:
- CommonSelenium::Element
- Defined in:
- lib/automation_object/driver/appium_adapter/element.rb
Overview
Element proxy for Appium Conform Appium element interface to what's expected of the Driver Port
Instance Method Summary collapse
-
#initialize(driver, element) ⇒ Element
constructor
A new instance of Element.
-
#scroll_into_view ⇒ void
Scroll the element into view.
Methods included from CommonSelenium::Element
#attribute, #clear, #click, #content, #hover, #href, #id, #invisible?, #send_keys, #submit, #switch_to_iframe, #text, #visible?
Methods included from CommonSelenium::ElementGeometry
#box_coordinates, #collides_with_element?, #element_center, #height, #location, #size, #width, #x, #y
Methods inherited from Proxy::Proxy
Constructor Details
#initialize(driver, element) ⇒ Element
Returns a new instance of Element
13 14 15 16 |
# File 'lib/automation_object/driver/appium_adapter/element.rb', line 13 def initialize(driver, element) @driver = driver @subject = element end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class AutomationObject::Proxy::Proxy
Instance Method Details
#scroll_into_view ⇒ void
This method returns an undefined value.
Scroll the element into view
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/automation_object/driver/appium_adapter/element.rb', line 20 def scroll_into_view @subject.location_once_scrolled_into_view # Only scroll better if this is a browser and not an app return unless @driver.browser? center = element_center @driver.execute_script("window.scroll(#{center[:x]},#{ideal_y_position});") # Just in case in close to the top or bottom bounds of the window element_location = @subject.location_once_scrolled_into_view return unless (element_location[:y]).negative? scroll_position = @driver.scroll_position scroll_y_position = scroll_position[:y] + element_location[:y] @driver.execute_script("window.scroll(#{element_location[:x]},#{scroll_y_position});") end |