Skip to content

Commit b12d61d

Browse files
authored
test: update scenario for ios 26 (#621)
* test: update for ios 26 * tweak more * Update test_helper.rb * Update driver_test.rb
1 parent 8baec17 commit b12d61d

5 files changed

Lines changed: 39 additions & 16 deletions

File tree

test/functional/common_w3c_actions.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
# limitations under the License.
1414

1515
# Scroll action for Android and iOS following W3C spec
16-
def w3c_scroll(driver)
16+
def w3c_scroll(driver, duration: 0.1)
1717
window = driver.window_rect
1818

1919
action_builder = driver.action
2020
input = action_builder.pointer_inputs[0]
2121
action_builder
2222
.move_to_location(window.width / 2, window.height * 8 / 10)
2323
.pointer_down(:left)
24-
.pause(device: input, duration: 0.1)
24+
.pause(device: input, duration: duration)
2525
.move_to_location(window.width / 2, window.height / 10, duration: 0.2)
26-
.pause(device: input, duration: 0.1)
26+
.pause(device: input, duration: duration)
2727
.release
2828
.perform
2929
end
-869 Bytes
Loading

test/functional/ios/driver_test.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
require 'test_helper'
16+
require 'functional/common_w3c_actions'
1617

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

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

122124
auto_correction = @@driver.wait do |d|
123-
d.find_element :predicate, 'name == "Auto-Correction" AND type == "XCUIElementTypeSwitch"'
125+
d.find_element :predicate, "name == \"#{auto_correction_name}\" AND type == \"XCUIElementTypeSwitch\""
124126
end
125-
search_word = over_ios17?(@@driver) ? 'Predictive Text' : 'Predictive'
127+
128+
# need to bring the element into the screen in ios 26
129+
w3c_scroll @@driver, duration: 1.0 if over_ios26? @@driver
130+
search_word = if over_ios26? @@driver
131+
'KeyboardPrediction'
132+
elsif over_ios17? @@driver
133+
'Predictive Text'
134+
else
135+
'Predictive'
136+
end
126137
predictive = @@driver.wait do |d|
127138
d.find_element :predicate, "name == \"#{search_word}\" AND type == \"XCUIElementTypeSwitch\""
128139
end

test/functional/ios/ios/mobile_commands_test.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
require 'test_helper'
16+
require 'functional/common_w3c_actions'
1617

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

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

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

97-
@driver.find_element(:accessibility_id, 'Calendars').click
98-
el = @driver.find_element(:accessibility_id, uicatalog)
99-
assert_equal '1', el.value
99+
privacy_name = over_ios26? @driver ? 'com.apple.settings.privacyAndSecurity' : 'Privacy'
100+
@driver.find_element(:accessibility_id, privacy_name).click
100101

102+
@driver.find_element(:accessibility_id, 'Calendars').click
103+
if over_ios26? @driver
104+
# without exceptions
105+
@driver.find_element :predicate, "label == 'UIKitCatalog, Full Access'"
106+
else
107+
el = @driver.find_element(:accessibility_id, uicatalog)
108+
assert_equal '1', el.value
109+
end
101110
@driver.back
102-
103-
@driver.find_element(:accessibility_id, 'Photos').click
104-
el = @driver.find_element(:accessibility_id, 'Never')
105-
assert_equal 'Never', el.value
106111
end
107112

108113
# @since Appium 1.10.0
@@ -118,6 +123,8 @@ def test_siri
118123

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

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

131139
@driver.activate_app 'com.example.apple-samplecode.UICatalog'

test/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def over_ios17?(driver)
8282
Gem::Version.create(driver.capabilities['platformVersion']) >= Gem::Version.create('17.0')
8383
end
8484

85+
def over_ios26?(driver)
86+
Gem::Version.create(driver.capabilities['platformVersion']) >= Gem::Version.create('26.0')
87+
end
88+
8589
def ci?
8690
ENV['CI'] == 'true'
8791
end

0 commit comments

Comments
 (0)