Class: Selenium::WebDriver::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/appium_lib_core/patch.rb

Overview

Implement useful features for element. Patch for Selenium Webdriver.

Instance Method Summary collapse

Instance Method Details

#labelString

Enable access to iOS accessibility label accessibility identifier is supported as ‘name’

Examples:


e = @driver.find_element :accessibility_id, 'something'
e.label

Returns:

  • (String)


46
47
48
# File 'lib/appium_lib_core/patch.rb', line 46

def label
  attribute :label
end

#location_rel(driver) ⇒ ::Selenium::WebDriver::Point

For use with location_rel.

Examples:


e = @driver.find_element :accessibility_id, 'something'
e.location_rel @driver

Returns:

  • (::Selenium::WebDriver::Point)

    the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/appium_lib_core/patch.rb', line 62

def location_rel(driver)
  rect = self.rect
  location_x = rect.x.to_f
  location_y = rect.y.to_f

  size_width  = rect.width.to_f
  size_height = rect.height.to_f

  center_x = location_x + (size_width / 2.0)
  center_y = location_y + (size_height / 2.0)

  w = driver.window_size
  ::Selenium::WebDriver::Point.new "#{center_x} / #{w.width.to_f}", "#{center_y} / #{w.height.to_f}"
end

#nameString

Returns the name attribute

Fixes NoMethodError: undefined method ‘name’ for Selenium::WebDriver::Element for iOS

Examples:


e = @driver.find_element :accessibility_id, 'something'
e.name

Returns:

  • (String)


33
34
35
# File 'lib/appium_lib_core/patch.rb', line 33

def name
  attribute :name
end

#valueString

Returns the value attribute

Fixes NoMethodError: undefined method ‘value’ for Selenium::WebDriver::Element for iOS

Examples:


e = @driver.find_element :accessibility_id, 'something'
e.value

Returns:

  • (String)


19
20
21
# File 'lib/appium_lib_core/patch.rb', line 19

def value
  attribute :value
end