Class: Selenium::WebDriver::Element

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

Overview

Implement useful features for element.

Instance Method Summary collapse

Instance Method Details

#location_relOpenStruct

For use with mobile tap.

“‘ruby execute_script ’mobile: tap’, :x => 0.0, :y => 0.98 “‘

github.com/appium/appium/wiki/Automating-mobile-gestures

Returns:

  • (OpenStruct)

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



58
59
60
61
62
63
# File 'lib/appium_lib/common/patch.rb', line 58

def location_rel
  xy = self.location
  w = window_size
  OpenStruct.new( x: xy.x.to_f / w.width.to_f,
                  y: xy.y.to_f / w.height.to_f )
end

#nameObject

Returns the name attribute

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



39
40
41
# File 'lib/appium_lib/common/patch.rb', line 39

def name
  self.attribute :name
end

#tag_nameObject

Returns the type attribute

Fixes Selenium::WebDriver::Error::UnknownError: Not yet implemented



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

def tag_name
  self.attribute :type
end

#valueObject

Returns the value attribute

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



32
33
34
# File 'lib/appium_lib/common/patch.rb', line 32

def value
  self.attribute :value
end