class AppPrism::Platforms::AppiumPlatform
Public Instance Methods
app_package()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 85 def app_package @driver.caps[:appPackage] end
find_element(identifiers)
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 7 def find_element(identifiers) @driver.find_element(identifiers) rescue Selenium::WebDriver::Error::NoSuchElementError raise "Cannot find such element: #{identifiers}" end
find_elements(identifiers)
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 26 def find_elements(identifiers) @driver.find_elements(identifiers) end
hide_keyboard()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 65 def hide_keyboard tries ||= 3 sleep 1 @driver.hide_keyboard rescue Selenium::WebDriver::Error::UnknownError retry unless (tries -= 1).zero? end
native_context?()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 81 def native_context? @driver.current_context == 'NATIVE_APP' end
refresh()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 13 def refresh start_x = screen_width/2 start_y = screen_height/2 end_y = start_y * 1.7 end_x = start_x @driver.swipe(start_x: start_x, start_y: start_y, end_x: end_x, end_y: end_y, duration: 1000) end
screen_height()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 34 def screen_height @driver.window_size.height end
screen_width()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 30 def screen_width @driver.window_size.width end
set_native_context()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 73 def set_native_context @driver.set_context('NATIVE_APP') end
set_web_context()
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 77 def set_web_context @driver.set_context("WEBVIEW_#{app_package}") end
swipe_down(element)
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 51 def swipe_down(element) location = element.location start_x = location.x + element.size.width/2 start_y = location.y + element.size.height * 0.05 end_y = location.y + element.size.height * 0.95 end_x = start_x @driver.swipe(start_x: start_x, start_y: start_y, end_x: end_x, end_y: end_y, duration: 3000) end
swipe_up(element)
click to toggle source
# File lib/app_prism/platforms/appium_platform.rb, line 38 def swipe_up(element) start_x = element.location.x + element.size.width/2 start_y = element.location.y + element.size.height * 0.95 end_y = element.location.y * 1.05 end_x = start_x @driver.swipe(start_x: start_x, start_y: start_y, end_x: end_x, end_y: end_y, duration: 3000) end