Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/functional/common_w3c_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
# limitations under the License.

# Scroll action for Android and iOS following W3C spec
def w3c_scroll(driver)
def w3c_scroll(driver, duration: 0.1)
window = driver.window_rect

action_builder = driver.action
input = action_builder.pointer_inputs[0]
action_builder
.move_to_location(window.width / 2, window.height * 8 / 10)
.pointer_down(:left)
.pause(device: input, duration: 0.1)
.pause(device: input, duration: duration)
.move_to_location(window.width / 2, window.height / 10, duration: 0.2)
.pause(device: input, duration: 0.1)
.pause(device: input, duration: duration)
.release
.perform
end
Binary file modified test/functional/data/test_ios_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions test/functional/ios/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

require 'test_helper'
require 'functional/common_w3c_actions'

# $ rake test:func:ios TEST=test/functional/ios/driver_test.rb
# rubocop:disable Style/ClassVars
Expand Down Expand Up @@ -117,12 +118,22 @@ def test_default_keyboard_pref
@@driver.find_element(:accessibility_id, 'Keyboard').click

# to wait the animation
@@driver.wait { |d| d.find_element :accessibility_id, 'Auto-Correction' }
auto_correction_name = over_ios26? @@driver ? 'KeyboardAutocorrection' : 'Auto-Correction'
@@driver.wait { |d| d.find_element :accessibility_id, auto_correction_name }

auto_correction = @@driver.wait do |d|
d.find_element :predicate, 'name == "Auto-Correction" AND type == "XCUIElementTypeSwitch"'
d.find_element :predicate, "name == \"#{auto_correction_name}\" AND type == \"XCUIElementTypeSwitch\""
end
search_word = over_ios17?(@@driver) ? 'Predictive Text' : 'Predictive'

# need to bring the element into the screen in ios 26
w3c_scroll @@driver, duration: 1.0 if over_ios26? @@driver
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fact potentially impacts automations...

search_word = if over_ios26? @@driver
'KeyboardPrediction'
elsif over_ios17? @@driver
'Predictive Text'
else
'Predictive'
end
predictive = @@driver.wait do |d|
d.find_element :predicate, "name == \"#{search_word}\" AND type == \"XCUIElementTypeSwitch\""
end
Expand Down
28 changes: 18 additions & 10 deletions test/functional/ios/ios/mobile_commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

require 'test_helper'
require 'functional/common_w3c_actions'

# $ rake test:func:ios TEST=test/functional/ios/ios/mobile_commands_test.rb
class AppiumLibCoreTest
Expand Down Expand Up @@ -83,26 +84,30 @@ def test_permission
core = ::Appium::Core.for(caps)
@driver = core.start_driver

skip 'Permissions does not work well on iOS 14 yet' if over_ios14?(@driver)

skip 'Not stable on CI' if ci?
# skip 'Permissions does not work well on iOS 14 yet' if over_ios14?(@driver)
assert @driver.execute_script('mobile: getPermission',
{ service: 'calendar', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'yes'
assert @driver.execute_script('mobile: getPermission',
{ service: 'photos', bundleId: 'com.example.apple-samplecode.UICatalog' }) == 'no'

@driver.terminate_app('com.apple.Preferences') # To ensure the app shows the top view
@driver.activate_app('com.apple.Preferences')
@driver.find_element(:accessibility_id, 'Privacy').click
@driver.settings.update({ defaultActiveApplication: 'com.apple.Preferences' })
w3c_scroll @driver, duration: 1.0

@driver.find_element(:accessibility_id, 'Calendars').click
el = @driver.find_element(:accessibility_id, uicatalog)
assert_equal '1', el.value
privacy_name = over_ios26? @driver ? 'com.apple.settings.privacyAndSecurity' : 'Privacy'
@driver.find_element(:accessibility_id, privacy_name).click

@driver.find_element(:accessibility_id, 'Calendars').click
if over_ios26? @driver
# without exceptions
@driver.find_element :predicate, "label == 'UIKitCatalog, Full Access'"
else
el = @driver.find_element(:accessibility_id, uicatalog)
assert_equal '1', el.value
end
@driver.back

@driver.find_element(:accessibility_id, 'Photos').click
el = @driver.find_element(:accessibility_id, 'Never')
assert_equal 'Never', el.value
end

# @since Appium 1.10.0
Expand All @@ -118,6 +123,8 @@ def test_siri

@driver.execute_script 'mobile: siriCommand', { text: 'hello, siri' }

# to expand the detection area
@driver.settings.update({ defaultActiveApplication: 'com.apple.springboard' })
if over_ios14?(@driver)
@core.wait { @driver.find_element :name, 'siri-interface-window' }
else
Expand All @@ -126,6 +133,7 @@ def test_siri
# name="...having a problem with the connection. Please try again in a little bit." ...>
@core.wait { @driver.find_element :class_chain, '**/*[`name == "com.apple.ace.assistant"`]' }
end
@driver.settings.update({ defaultActiveApplication: 'com.example.apple-samplecode.UICatalog' })
assert_equal :running_in_foreground, @driver.app_state('com.example.apple-samplecode.UICatalog')

@driver.activate_app 'com.example.apple-samplecode.UICatalog'
Expand Down
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def over_ios17?(driver)
Gem::Version.create(driver.capabilities['platformVersion']) >= Gem::Version.create('17.0')
end

def over_ios26?(driver)
Gem::Version.create(driver.capabilities['platformVersion']) >= Gem::Version.create('26.0')
end

def ci?
ENV['CI'] == 'true'
end
Expand Down
Loading