Skip to content

Commit

Permalink
add mobile alert (#575)
Browse files Browse the repository at this point in the history
* add mobile alert

* add comment
  • Loading branch information
KazuCocoa authored May 13, 2017
1 parent a2b0675 commit 1facf0f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
39 changes: 38 additions & 1 deletion ios_tests/lib/ios/specs/ios/xcuitest_gestures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <title>').displayed?
end
end

def open_alert_custom
wait_true do
find_element(:name, 'Show Customized').click
find_element(:name, 'UIActionSheet <title>').displayed?
end
end

t 'before_first' do
before_first
end
Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions lib/appium_lib/ios/xcuitest_gestures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1facf0f

Please sign in to comment.