Sha256: 287de1428317da8e2aa23c3c2ecddc1ea91e2a5fe11031ef935bc607c9cb7d41
Contents?: true
Size: 1.77 KB
Versions: 25
Compression:
Stored size: 1.77 KB
Contents
# encoding: utf-8 module Appium::Ios # iOS only # Tap the alert button identified by value. # # Click the ok button: # alert_click 'OK' # # Click the first button: # alert_click 0 # # @param value [Integer, String] either an integer index of the button or the button's name # @return [void] def alert_click value value = "'#{value}'" if value.is_a?(String) @driver.execute_script "UIATarget.localTarget().frontMostApp().alert().buttons()[#{value}].tap();" end # Get the alert message text. # @return [String] def alert_text # this will call get text twice so call bridge directly # ".switch_to.alert" calls it once, then ".text" another time. # @driver.switch_to.alert.text driver.send(:bridge).getAlertText end # Accept the alert. # @return [void] def alert_accept # @driver.switch_to.alert.accept # ".switch_to.alert" calls getAlertText so use bridge directly driver.send(:bridge).acceptAlert 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 # ".switch_to.alert" calls getAlertText so use bridge directly driver.send(:bridge).dismissAlert 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 end # module Appium::Ios
Version data entries
25 entries across 25 versions & 1 rubygems