diff --git a/test/functional/common_w3c_actions.rb b/test/functional/common_w3c_actions.rb index c6ade58c..ee546ff1 100644 --- a/test/functional/common_w3c_actions.rb +++ b/test/functional/common_w3c_actions.rb @@ -13,7 +13,7 @@ # 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 @@ -21,9 +21,9 @@ def w3c_scroll(driver) 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 diff --git a/test/functional/data/test_ios_button.png b/test/functional/data/test_ios_button.png index f77d882a..3b8c5d5c 100644 Binary files a/test/functional/data/test_ios_button.png and b/test/functional/data/test_ios_button.png differ diff --git a/test/functional/ios/driver_test.rb b/test/functional/ios/driver_test.rb index 42f015ba..cfd04b6a 100644 --- a/test/functional/ios/driver_test.rb +++ b/test/functional/ios/driver_test.rb @@ -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 @@ -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 + 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 diff --git a/test/functional/ios/ios/mobile_commands_test.rb b/test/functional/ios/ios/mobile_commands_test.rb index 15bf0c3d..45507cf2 100644 --- a/test/functional/ios/ios/mobile_commands_test.rb +++ b/test/functional/ios/ios/mobile_commands_test.rb @@ -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 @@ -83,8 +84,8 @@ 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', @@ -92,17 +93,21 @@ def test_permission @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 @@ -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 @@ -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' diff --git a/test/test_helper.rb b/test/test_helper.rb index 9bc96bae..c35caa20 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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