Skip to content

Commit 637a485

Browse files
Merge pull request #2392 from bugsnag/tms/appium-api
Do not use Maze.driver directly
2 parents 100e928 + 21af76e commit 637a485

4 files changed

Lines changed: 25 additions & 28 deletions

File tree

.buildkite/basic/react-native-ios-full-pipeline.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ steps:
6666
- "0.72"
6767
- "0.74"
6868
- "0.76"
69-
- "0.77"
69+
# TODO: 0.77 moved to the basic pipeline (where 0.78 has been skipped) pending PLAT-14005
70+
#- "0.77"
7071
retry:
7172
automatic:
7273
- exit_status: "*"
@@ -216,7 +217,7 @@ steps:
216217
concurrency: 5
217218
concurrency_group: "browserstack-app"
218219
concurrency_method: eager
219-
220+
220221
- label: ":bitbar: :mac: RN {{matrix}} iOS (Old Arch) end-to-end tests"
221222
depends_on: "build-react-native-ios-fixture-old-arch-full"
222223
timeout_in_minutes: 40
@@ -253,7 +254,8 @@ steps:
253254
- "0.72"
254255
- "0.74"
255256
- "0.76"
256-
- "0.77"
257+
# TODO: 0.77 moved to the basic pipeline (where 0.78 has been skipped) pending PLAT-14005
258+
#- "0.77"
257259

258260
- label: ":bitbar: :mac: RN {{matrix}} iOS (New Arch) end-to-end tests"
259261
depends_on: "build-react-native-ios-fixture-new-arch-full"

.buildkite/basic/react-native-ios-pipeline.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ steps:
2727
- "bundle install"
2828
- "node scripts/generate-react-native-fixture.js"
2929
matrix:
30-
- "0.78"
30+
# TODO: 0.78 moved back to 0.77 pending PLAT-14005
31+
- "0.77"
3132
retry:
3233
automatic:
3334
- exit_status: "*"
@@ -92,7 +93,8 @@ steps:
9293
concurrency_group: "bitbar"
9394
concurrency_method: eager
9495
matrix:
95-
- "0.78"
96+
# TODO: 0.78 moved back to 0.77 pending PLAT-14005
97+
- "0.77"
9698

9799
- label: ":bitbar: :mac: RN {{matrix}} iOS (New Arch) end-to-end tests"
98100
depends_on: "build-react-native-ios-fixture-new-arch"

test/react-native/features/steps/react-native-steps.rb

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,46 +50,39 @@ def execute_command(action, scenario_name = '', scenario_data = '')
5050
def wait_for_app_state(expected_state)
5151
max_attempts = 20
5252
attempts = 0
53-
state = get_app_state
53+
manager = Maze::Api::Appium::AppManager.new
54+
state = manager.state
5455
until (attempts >= max_attempts) || state == expected_state
5556
attempts += 1
56-
state = get_app_state
57+
state = manager.state
5758
sleep 0.5
5859
end
5960
$logger.warn "App state #{state} instead of #{expected_state} after 10s" unless state == expected_state
6061
state
6162
end
6263

63-
def get_app_state
64-
case Maze::Helper.get_current_platform
65-
when 'ios'
66-
Maze.driver.app_state('com.bugsnag.fixtures.reactnative')
67-
when 'android'
68-
Maze.driver.app_state('com.reactnative')
69-
end
70-
end
71-
7264
When('I relaunch the app after a crash') do
7365
state = wait_for_app_state :not_running
7466
# TODO: Really we should be using terminate_app/activate_app with the newer Appium client,
7567
# but for some reason they seem to make some scenarios flaky (presumably due to the
7668
# nature of how/when they close the app).
69+
manager = Maze::Api::Appium::AppManager.new
7770
if state != :not_running
78-
Maze.driver.close_app
79-
# Maze.driver.terminate_app Maze.driver.app_id
71+
manager.close
72+
# manager.terminate
8073
end
81-
Maze.driver.launch_app
82-
# Maze.driver.activate_app Maze.driver.app_id
74+
manager.launch
75+
# manager.activate
8376
end
8477

8578
When('I clear any error dialogue') do
8679
# Error dialogue is auto-cleared on IOS
87-
next unless Maze.driver.capabilities['os'] == 'android'
80+
next unless Maze::Helper.get_current_platform == 'android'
8881

89-
driver = Maze.driver
90-
driver.click_element('android:id/button1') if driver.wait_for_element('android:id/button1', 3)
91-
driver.click_element('android:id/aerr_close') if driver.wait_for_element('android:id/aerr_close', 3)
92-
driver.click_element('android:id/aerr_restart') if driver.wait_for_element('android:id/aerr_restart', 3)
82+
manager = Maze::Api::Appium::UiManager.new
83+
manager.click_element('android:id/button1') if manager.wait_for_element('android:id/button1', 3)
84+
manager.click_element('android:id/aerr_close') if manager.wait_for_element('android:id/aerr_close', 3)
85+
manager.click_element('android:id/aerr_restart') if manager.wait_for_element('android:id/aerr_restart', 3)
9386
end
9487

9588
When('I configure Bugsnag for {string}') do |scenario_name|
@@ -170,7 +163,7 @@ def get_app_state
170163
payload_value = Maze::Helper.read_key_path(payload, "events.0.#{field_path}")
171164

172165
expected_value = get_value_for_arch_and_version(table)
173-
166+
174167
unless expected_value.eql?('@skip')
175168
assert_equal_with_nullability(expected_value, payload_value)
176169
end

test/react-native/features/support/env.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Before do
1212
# See https://www.browserstack.com/docs/app-automate/appium/troubleshooting/app-orientation-issues
13-
Maze.driver.set_rotation(:portrait)
13+
Maze::Api::Appium::DeviceManager.new.set_rotation(:portrait)
1414
end
1515

1616
Before('@android_only') do |_scenario|
@@ -45,4 +45,4 @@
4545
Before('@skip_new_arch_below_074') do |scenario|
4646
current_version = ENV['RN_VERSION'].nil? ? 0 : ENV['RN_VERSION'].to_f
4747
skip_this_scenario("Skipping scenario") if ENV['RCT_NEW_ARCH_ENABLED'].eql?('1') && current_version < 0.74
48-
end
48+
end

0 commit comments

Comments
 (0)