Module: AutomationObject::Driver::CommonSelenium::Element
- Includes:
- ElementGeometry
- Included in:
- AppiumAdapter::Element, SeleniumAdapter::Element
- Defined in:
- lib/automation_object/driver/common_selenium/element.rb
Overview
Helper module for Selenium based elements
Instance Method Summary collapse
-
#attribute(key, value = false) ⇒ Object
Value of attribute.
-
#clear ⇒ void
Clear the element field.
-
#click ⇒ void
Perform a click action on the element.
-
#content ⇒ String?
Content of element.
-
#hover ⇒ Object
Hover over element.
-
#href ⇒ String?
Href of element.
-
#id ⇒ String?
Id of element.
-
#invisible? ⇒ Boolean
Element invisible.
-
#send_keys(string) ⇒ void
Type into an element.
-
#submit ⇒ void
Perform a submit action on an element.
-
#switch_to_iframe ⇒ Object
Helper method to switch to this element's iframe.
-
#text ⇒ String?
Text of element.
-
#visible? ⇒ Boolean
Element visible.
Methods included from ElementGeometry
#box_coordinates, #collides_with_element?, #element_center, #height, #location, #size, #width, #x, #y
Instance Method Details
#attribute(key, value = false) ⇒ Object
Returns value of attribute
47 48 49 50 51 52 53 54 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 47 def attribute(key, value = false) if value script = "return arguments[0].#{key} = '#{value}'" @driver.execute_script(script, @subject) end @subject.attribute(key) end |
#clear ⇒ void
This method returns an undefined value.
Clear the element field
64 65 66 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 64 def clear @subject.clear end |
#click ⇒ void
This method returns an undefined value.
Perform a click action on the element
76 77 78 79 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 76 def click scroll_into_view if @driver.browser? @subject.click end |
#content ⇒ String?
Returns content of element
40 41 42 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 40 def content @subject.attribute('content') end |
#hover ⇒ Object
Hover over element
82 83 84 85 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 82 def hover scroll_into_view @driver.action.move_to(@subject).perform end |
#href ⇒ String?
Returns href of element
29 30 31 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 29 def href @subject.attribute('href') end |
#id ⇒ String?
Returns id of element
24 25 26 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 24 def id @subject.attribute('id') end |
#invisible? ⇒ Boolean
Returns element invisible
19 20 21 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 19 def invisible? @subject.displayed? ? false : true end |
#send_keys(string) ⇒ void
This method returns an undefined value.
Type into an element
58 59 60 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 58 def send_keys(string) @subject.send_keys(string) end |
#submit ⇒ void
This method returns an undefined value.
Perform a submit action on an element
70 71 72 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 70 def submit @subject.submit end |
#switch_to_iframe ⇒ Object
Helper method to switch to this element's iframe
88 89 90 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 88 def switch_to_iframe @driver.switch_to.frame(iframe_switch_value) end |
#text ⇒ String?
Text of element
35 36 37 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 35 def text @subject.text end |
#visible? ⇒ Boolean
Returns element visible
14 15 16 |
# File 'lib/automation_object/driver/common_selenium/element.rb', line 14 def visible? @subject.displayed? end |