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
3 changes: 3 additions & 0 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ jobs:
- run: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false

- uses: futureware-tech/simulator-action@v6
id: simulator
with:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
model: ${{ env.IOS_DEVICE_NAME }}
os_version: ${{ env.IOS_VERSION }}
wait_for_boot: true

- name: Preparing other environment
run: |
Expand Down Expand Up @@ -79,6 +81,7 @@ jobs:
timeout-minutes: 60
working-directory: ios_tests
env:
IOS_UDID: ${{ steps.simulator.outputs.udid }}
LOCAL_PREBUILT_WDA: ${{ github.workspace }}/wda/WebDriverAgentRunner-Runner.app
- name: Save server output
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ New entries are maintained by Release Please.

Release tags are https://github.com/appium/ruby_lib/releases .

### Upgrading to core 14 (unreleased)

This library requires `appium_lib_core >= 14.0.0, < 15.0`.

- `wait` and `wait_true` now retry only `Selenium::WebDriver::Error::NoSuchElementError`
by default. Other errors, including assertion failures and interruptions, propagate
immediately. Use `ignored: [SomeTransientError]` to choose retryable exceptions;
this replaces the default list. Use `ignored: []` to disable exception retries.
`wait` still accepts false or nil results, while `wait_true` requires a truthy result.
- `Appium::Driver` continues to support `appium_lib: { wait: seconds }`, `default_wait`,
`no_wait`, and `set_wait`. The wrapper applies a configured implicit wait after each
session starts. Without that option, it sends no implicit-timeout command.
Direct `Appium::Core` users must configure `driver.manage.timeouts.implicit_wait`
themselves. `wait_timeout` controls explicit waits, not implicit waits.
- `element_screenshot` and `take_element_screenshot` remain available on
`Appium::Driver`; they now use core's `save_element_screenshot`.
- Replace `element.location_rel(driver)` with `element.rect`. To calculate the
center relative to the window, use `(rect.x + rect.width / 2.0) / window.width`
and `(rect.y + rect.height / 2.0) / window.height`.
- `Appium.symbolize_keys` is removed. Use symbol keys for client options or Ruby's
`transform_keys(&:to_sym)` where appropriate. The wrapper accepts string client
option keys without converting capability keys or nested capability values.
- Custom server responses must use the W3C element key
`element-6066-11e4-a52e-4f735466cecf`; legacy `ELEMENT` references are no longer supported.

See the [core 14 migration notes](https://github.com/appium/ruby_lib_core/blob/v14.0.0/CHANGELOG.md)
for changes affecting direct core API usage.

## [16.5.1](https://github.com/appium/ruby_lib/compare/v16.5.0...v16.5.1) (2026-11-06)


Expand Down
4 changes: 4 additions & 0 deletions android_tests/lib/android/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def start_test_activity(component)
end

def reset_test_app
AppiumTestSession.driver.set_context 'NATIVE_APP'
start_test_activity('io.appium.android.apis/.ApiDemos')
AppiumTestSession.driver.wait_true do
AppiumTestSession.driver.text_exact('NFC').displayed?
end
end
end
19 changes: 11 additions & 8 deletions android_tests/lib/android/specs/android/element/alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,44 @@ def teardown
end

def open_alert
# trigger the alert
# Click once, then wait for the dialog rather than matching its launch button again.
wait { button('OK Cancel dialog with a message').click }
wait_true do
button_exact('OK').displayed? && button_exact('Cancel').displayed?
end
end

def test_01_alert_click
# test
wait { open_alert }
open_alert
wait { alert_click('OK') }
end

def test_02_alert_accept
wait { open_alert }
open_alert
wait { alert_accept }
end

def test_03_alert_accept_text
wait { open_alert }
wait { assert_equal alert_accept_text, 'OK' }
open_alert
wait_true { alert_accept_text == 'OK' }
wait { alert_accept }
end

def test_04_alert_dismiss
wait { open_alert }
open_alert
wait { alert_dismiss }
end

def test_05_alert_dismiss_text
wait { open_alert }
open_alert

# alert dialog button placement changed:
# 'OK Cancel dialog with a long message'
# Android L: 'Something, Cancel, Ok'
# Android 19: 'Cancel, Something, Ok'

wait { assert_equal alert_dismiss_text.downcase, 'cancel' }
wait_true { alert_dismiss_text.downcase == 'cancel' }
wait { alert_dismiss }
end
end
Expand Down
14 changes: 11 additions & 3 deletions android_tests/lib/android/specs/common/device_touchaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,20 @@ def test_04_swipe
wait { text('Animation').click }
wait { text_exact('Bouncing Balls').click }

# W3C actions take pixels, not ratios; avoid swiping from the system status bar.
size = driver.window_size
x = (size.width * 0.75).to_i
start_y = (size.height * 0.25).to_i
end_y = (size.height * 0.5).to_i
driver.action
.move_to_location(0.75, 0.25).pointer_down(:left)
.move_to_location(0.75, 50)
.move_to_location(x, start_y).pointer_down(:left)
.move_to_location(x, end_y)
.release.perform

3.times { back }
# Bouncing Balls -> Animation -> ApiDemos. A third Back exits the app.
back
wait { text_exact('Bouncing Balls') }
back
wait { text_exact 'NFC' }
end

Expand Down
22 changes: 10 additions & 12 deletions android_tests/lib/android/specs/common/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ def test_01_wait
wait(wait_opts) { nil }

# failed wait should error
assert_raises ::Appium::Core::Wait::TimeoutError do
wait(wait_opts) { raise }
assert_raises RuntimeError do
wait(wait_opts) { raise 'wait condition failed' }
end

# regular rescue will not handle exceptions outside of StandardError hierarchy
# must rescue Exception explicitly to rescue everything
assert_raises ::Appium::Core::Wait::TimeoutError do
# Wait helpers propagate errors outside their default retry list.
assert_raises NoMemoryError do
wait(wait_opts) { raise NoMemoryError }
end

assert_raises ::Appium::Core::Wait::TimeoutError do
assert_raises NoMemoryError do
wait(timeout: 0.2, interval: 0.0) { raise NoMemoryError }
end

Expand Down Expand Up @@ -78,17 +77,16 @@ def test_03_wait_true
end

# raise should error
assert_raises ::Appium::Core::Wait::TimeoutError do
wait_true(wait_opts) { raise }
assert_raises RuntimeError do
wait_true(wait_opts) { raise 'wait condition failed' }
end

# regular rescue will not handle exceptions outside of StandardError hierarchy
# must rescue Exception explicitly to rescue everything
assert_raises ::Appium::Core::Wait::TimeoutError do
# Wait helpers propagate errors outside their default retry list.
assert_raises NoMemoryError do
wait_true(wait_opts) { raise NoMemoryError }
end

assert_raises ::Appium::Core::Wait::TimeoutError do
assert_raises NoMemoryError do
wait_true(timeout: 0.2, interval: 0.0) { raise NoMemoryError }
end

Expand Down
43 changes: 25 additions & 18 deletions android_tests/lib/android/specs/common/patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
class AndroidTest
class Common
class Patch < Minitest::Test
include AndroidTestNavigation

def setup
super
reset_test_app
wait_true { text_exact('API Demos').displayed? }
end

def teardown
reset_test_app
ensure
super
end

# Attributes are busted in Android.
# Blocked on https://github.com/appium/appium/issues/628

Expand All @@ -34,11 +48,11 @@ def test_01_element_method_name

# def test_01_tag_name' do; end # Doesn't work on And

def test_02_element_method_location_rel
def test_02_element_method_rect
wait do
loc = first_text.location_rel(AppiumTestSession.driver)
assert_equal loc.x.class, String
assert_equal loc.y.class, String
rect = first_text.rect
assert_kind_of Numeric, rect.x
assert_kind_of Numeric, rect.y
end
end

Expand All @@ -59,30 +73,23 @@ def test_03_common_patch_id_error_message
end

def test_04_id_common_patch_success
if automation_name_is_uiautomator2?
wait do
el = text 'text' # <string name="autocomplete_3_button_7">Text</str
assert_equal el.text, 'Text'
end
else
wait do
el = id 'autocomplete_3_button_7' # <string name="autocomplete_3_button_7">Text</string>
assert_equal el.text, 'Text'
end
wait do
expected = find_element(:id, 'android:id/text1')
assert_equal expected, id('android:id/text1')
end
end

def test_05_find_many_elements_by_resource_id
wait do
wait(ignored: [Minitest::Assertion, Selenium::WebDriver::Error::NoSuchElementError]) do
value = find_elements(:id, 'android:id/text1').length
assert_equal value, 12
assert_equal 12, value
end
end

def test_06_find_single_element_by_resource_id
wait do
wait(ignored: [Minitest::Assertion, Selenium::WebDriver::Error::NoSuchElementError]) do
value = id('android:id/text1').text
assert_equal value, "Access'ibility"
assert_equal "Access'ibility", value
end
end
end
Expand Down
45 changes: 21 additions & 24 deletions android_tests/lib/android/specs/common/web_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,43 @@
class AndroidTest
class Common
class WebContext < Minitest::Test
# appium's context support is broken on android
include AndroidTestNavigation

def setup
super
reset_test_app
end

def teardown
reset_test_app
ensure
super
end

def test_01_available_contexts
wait_true { available_contexts.include? 'NATIVE_APP' }
end

def test_02_current_context
wait { assert_equal current_context, 'NATIVE_APP' }
end

def undo_setcontext_nav
back
wait { find('WebView') }
back
wait { find 'Views' }
assert_equal 'NATIVE_APP', current_context
end

def test_03_set_context
wait { scroll_to('Views').click }
wait { scroll_to('WebView').click }

wait_true { !available_contexts.detect { |e| e.start_with?('WEBVIEW') }.nil? }
wait { scroll_to_exact('Views') }.click
wait { scroll_to_exact('WebView') }.click

webview_context = available_contexts.detect { |e| e.start_with?('WEBVIEW') }

if webview_context.nil?
undo_setcontext_nav
raise "No webview context found. contexts are: #{contexts}"
webview_context = wait_true do
available_contexts.find { |context| context.start_with?('WEBVIEW') }
end

wait { set_context webview_context }
wait { assert_equal current_context, webview_context }
set_context webview_context
wait_true { current_context == webview_context }

# verify inspect within webview works
assert get_android_inspect.split("\n").length >= 3

wait { set_context 'NATIVE_APP' }
wait { assert_equal current_context, 'NATIVE_APP' }

undo_setcontext_nav
set_context 'NATIVE_APP'
wait_true { current_context == 'NATIVE_APP' }
end
end
end
Expand Down
1 change: 1 addition & 0 deletions android_tests/lib/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def start_driver(caps)
caps[:caps][:app] = ENV['IOS_APP'] if ENV['IOS_APP']
caps[:caps][:platformVersion] = ENV['IOS_VERSION'] if ENV['IOS_VERSION']
caps[:caps][:deviceName] = ENV['IOS_DEVICE_NAME'] if ENV['IOS_DEVICE_NAME']
caps[:caps][:udid] = ENV['IOS_UDID'] if ENV['IOS_UDID']
end

if ENV['LOCAL_PREBUILT_WDA']
Expand Down
2 changes: 1 addition & 1 deletion appium_lib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
s.require_paths = ['lib']

s.add_dependency 'appium_lib_core', '>= 13.0.0', '< 14.0'
s.add_dependency 'appium_lib_core', '>= 14.0.0', '< 15.0'
s.add_dependency 'nokogiri', '~> 1.8', '>= 1.8.1'
s.add_dependency 'ostruct', '~> 0.6'
s.add_dependency 'tomlrb', '>= 1.1', '< 4.0'
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ e.tag_name # calls .type (patch.rb)
e.text
e.size
e.location
e.location_rel
e.rect # position and size; location_rel was removed in core 14
e.click
e.send_keys 'keys to send'
e.displayed? # true or false depending if the element is visible
Expand Down
Loading
Loading