diff --git a/ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb b/ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb
index 4eba9210..0d66e4e6 100644
--- a/ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb
+++ b/ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb
@@ -8,6 +8,20 @@ def after_last
screen.must_equal catalog
end
+ def open_alert_ok_cancel
+ wait_true do
+ find_element(:name, 'Show OK-Cancel').click
+ find_element(:name, 'UIActionSheet
').displayed?
+ end
+ end
+
+ def open_alert_custom
+ wait_true do
+ find_element(:name, 'Show Customized').click
+ find_element(:name, 'UIActionSheet ').displayed?
+ end
+ end
+
t 'before_first' do
before_first
end
@@ -58,8 +72,31 @@ def after_last
find_element(:name, 'Serena Auroux').displayed?.must_equal true
end
- t 'after_last' do
+ t 'back to top' do
+ back_click
+ end
+
+ t 'alert' do
+ wait_true do
+ UI::Inventory.xcuitest? ? find_element(:name, 'Alerts').click : text('alerts').click
+ tag(UI::Inventory.navbar).name == 'Alerts' # wait for true
+ end
+
+ open_alert_ok_cancel
+ alert action: 'accept'
+
+ open_alert_ok_cancel
+ alert action: 'dismiss'
+
+ open_alert_custom
+ alert action: 'accept', button_label: 'Button1'
+ end
+
+ t 'back to top' do
back_click
+ end
+
+ t 'after_last' do
after_last
end
end
diff --git a/lib/appium_lib/ios/xcuitest_gestures.rb b/lib/appium_lib/ios/xcuitest_gestures.rb
index a23fcd2f..eb68ac78 100644
--- a/lib/appium_lib/ios/xcuitest_gestures.rb
+++ b/lib/appium_lib/ios/xcuitest_gestures.rb
@@ -142,6 +142,23 @@ def select_picker_wheel(element:, order:, offset: nil)
args[:offset] = offset if offset
execute_script 'mobile: selectPickerWheelValue', args
end
+
+ # @param action [String] The following actions are supported: accept, dismiss and getButtons. Mandatory parameter
+ # @param button_label [String] The label text of an existing alert button to click on.
+ # This is an optional parameter and is only valid in combination with accept and dismiss actions.
+ # @return nil or Selenium::WebDriver::Error::NoSuchAlertError if no action sheet or alert
+ #
+ # ```ruby
+ # alert action: "accept"
+ # alert action: "dismiss"
+ # ```
+ def alert(action:, button_label: nil)
+ return 'Set "accept", "dismiss" or "getButtons" for :action' unless %w(accept dismiss getButtons).include?(action)
+
+ args = { action: action }
+ args[:button_label] if button_label
+ execute_script 'mobile: alert', args
+ end
end # module XcuitestGesture
end # module Ios
end # module Appium