Skip to content

Commit ecee089

Browse files
authored
feat: work with Ruby 3 (#893)
* fix ios/driver * fix web context in ios * tweak more * tweak tests * renamed from tap to tap_once to avoid conflict in Ruby tap * tweak ios * fix more * tweak * fix tests * fix rubocop * update changelog * tweak * tweak tests
1 parent bb3d715 commit ecee089

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+181
-216
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ Release tags are https://github.com/appium/ruby_lib/releases .
55

66
## Unreleased
77

8+
Support Ruby 3
9+
810
### 1. Enhancements
911

1012
### 2. Bug fixes
1113

1214
### 3. Deprecations
15+
- Rename `Appium::Ios::Xcuitest::Guesture#tap` to `Appium::Ios::Xcuitest::Guesture#one_finger_tap` to prevent conflicts with `tap` in Ruby
1316

1417
## 11.0.0 - 2020-12-19
1518

android_tests/appium.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[caps]
22
automationName = "uiautomator2"
33
platformName = "android"
4-
deviceName = "Nexus 7"
4+
deviceName = "Android emulator"
55
app = "../test_apps/api.apk"
66
appPackage = "io.appium.android.apis"
77
appActivity = "io.appium.android.apis.ApiDemos"
88
some_capability = "some_capability"
99

10+
1011
[appium_lib]
1112
sauce_username = ""
1213
sauce_access_key = ""

android_tests/lib/android/specs/android/element/alert.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[android/element/alert]
15+
# rake "android[android/element/alert]"
1616
describe 'android/element/alert' do
1717
def open_alert
1818
# trigger the alert

android_tests/lib/android/specs/android/element/button.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android['android/element/button']
15+
# rake "android[android/element/button]"
1616
describe 'android/element/button' do
1717
def before_first
1818
# nav to buttons activity
@@ -27,11 +27,7 @@ def after_last
2727
end
2828

2929
def fade_in
30-
if automation_name_is_espresso?
31-
'Fade in'
32-
else
33-
'FADE IN'
34-
end
30+
'Fade in'
3531
end
3632

3733
t { before_first }

android_tests/lib/android/specs/android/element/generic.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android['android/element/generic']
15+
# rake "android[android/element/generic]"
1616
describe 'android/element/generic' do
1717
def content
1818
'Content'

android_tests/lib/android/specs/android/element/text.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android['android/element/text']
15+
# rake "android[android/element/text]"
1616
describe 'android/element/text' do
1717
def must_raise_no_element
1818
proc { yield }.must_raise Selenium::WebDriver::Error::NoSuchElementError

android_tests/lib/android/specs/android/element/textfield.rb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# rake "android[android/element/textfield]"
1516
describe 'android/element/textfield' do
1617
def must_raise_no_element
1718
proc { yield }.must_raise Selenium::WebDriver::Error::NoSuchElementError

android_tests/lib/android/specs/android/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[android/helper]
15+
# rake "android[android/helper]"
1616
describe 'android/helper' do
1717
t 'tags' do
1818
wait { tags('android.widget.TextView').length.must_equal 13 }

android_tests/lib/android/specs/android/patch.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[android/patch]
15+
# rake "android[android/patch]"
1616
describe 'android/patch.rb' do
1717
t 'type' do
1818
# nav to textfield

android_tests/lib/android/specs/common/command/command.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[common/command/command]
15+
# rake "android[common/command/command]"
1616
describe 'common/command/command' do
1717
t 'command' do
1818
File.delete 'logcat.log' if File.exist? 'logcat.log'

android_tests/lib/android/specs/common/device.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[common/device]
15+
# rake "android[common/device]"
1616
describe 'common/device' do
1717
t 'get_performance_data_types' do
1818
expected = %w(batteryinfo cpuinfo memoryinfo networkinfo)

android_tests/lib/android/specs/common/device_touchaction.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[common/device_touchaction]
15+
# rake "android[common/device_touchaction]"
1616
describe 'common/device_touchaction' do
1717
def before_first
1818
wait { text('Accessibility') }

android_tests/lib/android/specs/common/element/window.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[common/element/window]
15+
# rake "android[common/element/window]"
1616
describe 'common/element/window' do
1717
# rubocop:disable Lint/UnifiedInteger
1818
t 'window_size' do

android_tests/lib/android/specs/common/helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# rake "android[common/helper]"
1516
describe 'common/helper' do
1617
wait_opts = { timeout: 0.2, interval: 0.2 } # max_wait, interval
1718

android_tests/lib/android/specs/common/patch.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# status # status patches are already tested in driver.rb
1717
# execute # debug output for Pry
1818

19+
# rake "android[common/patch]"
1920
describe 'common/patch' do
2021
# Attributes are busted in Android.
2122
# Blocked on https://github.com/appium/appium/issues/628

android_tests/lib/android/specs/common/web_context.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
# Tests specifically for areas where the web_context differs in behaviour
16-
# rake android[common/web_context]
16+
# rake "android[common/web_context]"
1717
describe 'the web context' do
1818
# appium's context support is broken on android
1919

@@ -36,8 +36,9 @@ def undo_setcontext_nav
3636
wait { find 'Views' }
3737
end
3838

39-
contexts = available_contexts
40-
webview_context = contexts.detect { |e| e.start_with?('WEBVIEW') }
39+
wait_true { !available_contexts.detect { |e| e.start_with?('WEBVIEW') }.nil? }
40+
41+
webview_context = available_contexts.detect { |e| e.start_with?('WEBVIEW') }
4142

4243
if webview_context.nil?
4344
undo_setcontext_nav

android_tests/lib/android/specs/device/touch_actions.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[device/touch_actions]
15+
# rake "android[device/touch_actions]"
1616
describe 'device/touch_actions' do
1717
def swipe_till_text_visible(seen_text)
1818
start_x = window_size[:width] / 2
1919
start_y = window_size[:height] / 2
20-
wait(timeout: 0.6) do
20+
wait(timeout: 1.0) do
2121
# rubocop:disable Layout/LineLength
2222
# Example for Android's log
2323
# [0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, end_x: start_y, end_y: start_y - 100
@@ -32,7 +32,7 @@ def swipe_till_text_visible(seen_text)
3232
# [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Swiping from [x=600.0, y=919.0] to [x=600.0, y=819.0] with steps: 6
3333
# [debug] [AndroidBootstrap] Received command result from bootstrap
3434
# rubocop:enable Layout/LineLength
35-
swipe start_x: start_x, start_y: start_y, end_x: 0.0, end_y: - 100
35+
swipe start_x: start_x, start_y: start_y, end_x: 0.0, end_y: 10
3636
text(seen_text).displayed?
3737
end
3838
end
@@ -44,7 +44,7 @@ def swipe_till_text_visible(seen_text)
4444
text('animation').displayed?
4545
end
4646
text('animation').text.must_equal 'Animation'
47-
swipe_till_text_visible('lists')
47+
swipe_till_text_visible('Views')
4848
end
4949
end
5050

android_tests/lib/android/specs/driver.rb

+3-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake android[driver]
15+
# rake "android[driver]"
1616
describe 'driver' do
1717
def sauce?
1818
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
@@ -48,7 +48,6 @@ def sauce?
4848

4949
t 'verify all attributes' do
5050
actual = driver_attributes
51-
caps_app_for_teardown = actual[:caps][:app]
5251
expected_app = File.absolute_path('../test_apps/api.apk')
5352

5453
expected = {
@@ -74,7 +73,7 @@ def sauce?
7473
caps_with_json['app'].must_equal expected_app
7574
caps_with_json['appPackage'].must_equal 'io.appium.android.apis'
7675
caps_with_json['appActivity'].must_equal 'io.appium.android.apis.ApiDemos'
77-
caps_with_json['deviceName'].must_equal 'Nexus 7'
76+
caps_with_json['deviceName'].must_equal 'Android emulator'
7877
caps_with_json['someCapability'].must_equal 'some_capability'
7978

8079
actual[:caps][:platformName].must_equal 'android'
@@ -87,17 +86,7 @@ def sauce?
8786
dup_actual = actual.dup
8887
dup_actual.delete(:caps)
8988

90-
if dup_actual != expected
91-
diff = HashDiff.diff expected, dup_actual
92-
diff = "diff (expected, actual):\n#{diff}"
93-
94-
dup_actual[:caps][:app] = caps_app_for_teardown if dup_actual.key? :caps
95-
# example:
96-
# change :ios in expected to match 'ios' in actual
97-
# [["~", "caps.platformName", :ios, "ios"]]
98-
message = "\n\nactual:\n\n: #{dup_actual}expected:\n\n#{expected}\n\n#{diff}"
99-
raise message
100-
end
89+
raise "\n\nactual:\n\n: #{dup_actual}expected:\n\n#{expected}" if dup_actual != expected
10190
end
10291
end
10392

android_tests/lib/android/specs/install.rb

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# rake "android[install]"
1516
describe 'install' do
1617
# To Do: Blocked on https://github.com/appium/appium/issues/3032
1718
def pkg

android_tests/lib/run.rb

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def start_driver(caps)
7171

7272
start_driver(caps)
7373

74+
# Ruby 3.0 sorts the Dir.glob order
7475
# require support (common.rb)
7576
file_name = File.join dir, "#{test_dir}/*.rb"
7677
Dir.glob(file_name) do |test|

grid/appium.txt.ios.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[caps]
22
platformName = "ios"
33
platformVersion = "11.4"
4-
deviceName ="iPhone Simulator"
4+
deviceName ="iPhone 11"
55
automationName = 'XCUITest'
66
app = "/absolute/path/to/UICatalog.app.zip"
77
some_capability = "some_capability"

grid/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"capabilities":
33
[
44
{
5-
"browserName": "iPhone Simulator",
5+
"browserName": "iPhone 11",
66
"version":"11.4",
77
"platform":"ios",
88
"maxInstances": 1

grid/hub_config_3.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"capabilities":
33
[
44
{
5-
"browserName": "iPhone Simulator",
5+
"browserName": "iPhone 11",
66
"version":"11.4",
77
"maxInstances": 1,
88
"seleniumProtocol": "WebDriver"

ios_tests/appium.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[caps]
22
platformName = "ios"
3-
platformVersion = "12.4"
4-
deviceName ="iPhone Simulator"
3+
platformVersion = "14.2"
4+
deviceName ="iPhone 11"
55
automationName = 'XCUITest'
66
app = "../test_apps/UICatalog.app.zip"
77
someCapability = "some_capability"

ios_tests/lib/common.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def leave_textfields
2525
def go_to_textfields
2626
screen.must_equal catalog
2727
wait_true do
28-
automation_name_is_xcuitest? ? find_element(:name, 'TextFields').click : text('textfield').click
29-
screen == 'TextFields' # wait for screen transition
28+
automation_name_is_xcuitest? ? find_element(:name, 'Text Fields').click : text('textfield').click
29+
screen == 'Text Fields' # wait for screen transition
3030
end
3131
end
3232

@@ -75,6 +75,10 @@ def picker
7575
xcuitest? ? 'XCUIElementTypePicker' : 'UIAPicker'
7676
end
7777

78+
def picker_wheel
79+
xcuitest? ? 'XCUIElementTypePickerWheel' : 'UIAPickerWheel'
80+
end
81+
7882
def action_sheet
7983
xcuitest? ? 'XCUIElementTypeActionSheet' : 'UIActionSheet'
8084
end

ios_tests/lib/ios/specs/common/command/command.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake ios[common/command/command]
15+
# rake "ios[common/command/command]"
1616
describe 'common/command/command' do
1717
t 'command' do
1818
File.delete 'syslog.log' if File.exist? 'syslog.log'

ios_tests/lib/ios/specs/common/element/window.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# rake ios[common/element/window]
15+
# rake "ios[common/element/window]"
1616
describe 'common/element/window' do
1717
def before_first
1818
screen.must_equal catalog

0 commit comments

Comments
 (0)