Class: Appium::Core::Base::Bridge::W3C

Inherits:
Selenium::WebDriver::Remote::W3C::Bridge
  • Object
show all
Defined in:
lib/appium_lib_core/common/base/bridge/w3c.rb

Instance Method Summary collapse

Instance Method Details

#action(async = false) ⇒ Object Also known as: actions

Examples:


element = @driver.find_element(:id, "some id")
@driver.action.click(element).perform # The `click` is a part of `PointerActions`


29
30
31
32
33
34
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 29

def action(async = false)
  ::Selenium::WebDriver::W3CActionBuilder.new self,
                                              ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'touch'),
                                              ::Selenium::WebDriver::Interactions.key('keyboard'),
                                              async
end

#available_log_typesObject

logs

For Appium No implementation for W3C webdriver module



121
122
123
124
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 121

def available_log_types
  types = execute :get_available_log_types
  Array(types).map(&:to_sym)
end

#commands(command) ⇒ Object



10
11
12
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 10

def commands(command)
  ::Appium::Core::Commands::COMMANDS_EXTEND_W3C[command]
end

#element_attribute(element, name) ⇒ Object

For Appium override



53
54
55
56
57
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 53

def element_attribute(element, name)
  # For W3C
  # execute_atom :getAttribute, element, name
  execute :get_element_attribute, id: element.ref, name: name
end

#find_element_by(how, what, parent = nil) ⇒ Object

For Appium override



61
62
63
64
65
66
67
68
69
70
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 61

def find_element_by(how, what, parent = nil)
  how, what = convert_locators(how, what)

  id = if parent
         execute :find_child_element, { id: parent }, { using: how, value: what }
       else
         execute :find_element, {}, { using: how, value: what }
       end
  ::Selenium::WebDriver::Element.new self, element_id_from(id)
end

#find_elements_by(how, what, parent = nil) ⇒ Object

For Appium override



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 74

def find_elements_by(how, what, parent = nil)
  how, what = convert_locators(how, what)

  ids = if parent
          execute :find_child_elements, { id: parent }, { using: how, value: what }
        else
          execute :find_elements, {}, { using: how, value: what }
        end

  ids.map { |id| ::Selenium::WebDriver::Element.new self, element_id_from(id) }
end

#get_timeoutsObject



37
38
39
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 37

def get_timeouts
  execute :get_timeouts
end

#locationObject

For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation`



103
104
105
106
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 103

def location
  obj = execute(:get_location) || {}
  ::Selenium::WebDriver::Location.new obj['latitude'], obj['longitude'], obj['altitude']
end

#log(type) ⇒ Object

For Appium No implementation for W3C webdriver module



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 128

def log(type)
  data = execute :get_log, {}, { type: type.to_s }

  Array(data).map do |l|
    begin
      ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
    rescue KeyError
      next
    end
  end
end

#network_connectionObject

For Appium override called in ‘extend DriverExtensions::HasNetworkConnection`



89
90
91
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 89

def network_connection
  execute :get_network_connection
end

#network_connection=(type) ⇒ Object

For Appium override called in ‘extend DriverExtensions::HasNetworkConnection`



96
97
98
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 96

def network_connection=(type)
  execute :set_network_connection, {}, { parameters: { type: type } }
end

#page_sourceObject

For Appium override



43
44
45
46
47
48
49
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 43

def page_source
  # For W3C
  # execute_script('var source = document.documentElement.outerHTML;' \
  # 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
  # 'return source;')
  execute :get_page_source
end

#set_location(lat, lon, alt) ⇒ Object

For Appium No implementation for W3C webdriver module called in ‘extend DriverExtensions::HasLocation`



111
112
113
114
# File 'lib/appium_lib_core/common/base/bridge/w3c.rb', line 111

def set_location(lat, lon, alt)
  loc = { latitude: lat, longitude: lon, altitude: alt }
  execute :set_location, {}, { location: loc }
end