Sha256: fcd85c8f65c8419f6fd3381f043754ffab02a598c16657ca9c9e525bd01c5f1e

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8

# iOS only
# Tap the alert button identified by value.
# @param value [Integer, String] either an integer index of the button or the button's name
# @return [void]
def alert_click value
  $driver.execute_script "UIATarget.localTarget().frontMostApp().alert().buttons()[#{value}].tap();"
end

# Get the alert message text.
# @return [String]
def alert_text
  $driver.switch_to.alert.text
end

# Accept the alert.
# @return [void]
def alert_accept
  $driver.switch_to.alert.accept
end

# Get the text of the alert's accept button.
# The last button is considered "accept."
# @return [String]
def alert_accept_text
  a = $driver.find_element(:tag_name, :alert)
  return if a.nil?
  b = a.find_elements(:tag_name, :button)
  b.last.text if b && b.size >= 1
end

# Dismiss the alert.
# @return [void]
def alert_dismiss
  $driver.switch_to.alert.dismiss
end

# Get the text of the alert's dismiss button.
# The first button is considered "dismiss."
# @return [String]
def alert_dismiss_text
  a = $driver.find_element(:tag_name, :alert)
  return if a.nil?
  b = a.find_elements(:tag_name, :button)
  b.first.text if b && b.size >= 1
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
appium_lib-0.0.25 lib/appium_lib/element/alert.rb
appium_lib-0.0.24 lib/appium_lib/element/alert.rb
appium_lib-0.0.23 lib/appium_lib/element/alert.rb
appium_lib-0.0.22 lib/appium_lib/element/alert.rb
appium_lib-0.0.21 lib/appium_lib/element/alert.rb