diff --git a/docker-compose.yml b/docker-compose.yml index eaac4e50eb..0afcead286 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -217,7 +217,7 @@ services: - ./test/react-native-cli/features/:/app/features react-native-maze-runner: - image: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v6-cli + image: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v7-cli environment: BUILDKITE: BUILDKITE_BRANCH: diff --git a/test/react-native/Gemfile b/test/react-native/Gemfile index 11f935399a..4eb2c78891 100644 --- a/test/react-native/Gemfile +++ b/test/react-native/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gem 'cocoapods' -gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v6.9.1' +gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', tag: 'v7.7.0' # Use a branch of Maze Runner #gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner', branch: 'tms/use-maze-check' diff --git a/test/react-native/Gemfile.lock b/test/react-native/Gemfile.lock index 9e69325aa5..4a81844517 100644 --- a/test/react-native/Gemfile.lock +++ b/test/react-native/Gemfile.lock @@ -1,10 +1,11 @@ GIT remote: https://github.com/bugsnag/maze-runner - revision: 912006496701a0b70191470d8ec612367e5f4b4f - tag: v6.9.1 + revision: 07e5d231773bc740b1d8de4d5c311b5c73f86e12 + tag: v7.7.0 specs: - bugsnag-maze-runner (6.9.1) - appium_lib (~> 11.2.0) + bugsnag-maze-runner (7.7.0) + appium_lib (~> 12.0) + appium_lib_core (~> 5.4.0) bugsnag (~> 6.24) cucumber (~> 7.1) cucumber-expressions (~> 6.0.0) @@ -13,7 +14,7 @@ GIT os (~> 1.0.0) rake (~> 12.3.3) rubyzip (~> 2.3.2) - selenium-webdriver (~> 3.11) + selenium-webdriver (~> 4.0) test-unit (~> 3.5.2) webrick (~> 1.7.0) @@ -33,18 +34,18 @@ GEM algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) - appium_lib (11.2.0) - appium_lib_core (~> 4.1) + appium_lib (12.0.1) + appium_lib_core (~> 5.0) nokogiri (~> 1.8, >= 1.8.1) - tomlrb (~> 1.1) - appium_lib_core (4.7.1) + tomlrb (>= 1.1, < 3.0) + appium_lib_core (5.4.0) faye-websocket (~> 0.11.0) - selenium-webdriver (~> 3.14, >= 3.14.1) + selenium-webdriver (~> 4.2, < 4.6) atomos (0.1.3) - bugsnag (6.24.2) + bugsnag (6.25.0) concurrent-ruby (~> 1.0) builder (3.2.4) - childprocess (3.0.0) + childprocess (4.1.0) claide (1.1.0) cocoapods (1.11.2) addressable (~> 2.8) @@ -136,38 +137,41 @@ GEM mime-types (3.4.1) mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) - mini_portile2 (2.7.1) + mini_portile2 (2.8.0) minitest (5.15.0) molinillo (0.8.0) multi_test (0.1.2) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - nokogiri (1.13.1) - mini_portile2 (~> 2.7.0) + nokogiri (1.13.9) + mini_portile2 (~> 2.8.0) racc (~> 1.4) optimist (3.0.1) os (1.0.1) - power_assert (2.0.1) + power_assert (2.0.2) public_suffix (4.0.6) - racc (1.6.0) + racc (1.6.1) rake (12.3.3) rexml (3.2.5) ruby-macho (2.5.1) rubyzip (2.3.2) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) + selenium-webdriver (4.5.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) sys-uname (1.2.2) ffi (~> 1.1) - test-unit (3.5.3) + test-unit (3.5.5) power_assert - tomlrb (1.3.0) + tomlrb (2.0.3) typhoeus (1.4.0) ethon (>= 0.9.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) webrick (1.7.0) + websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/test/react-native/features/steps/react-native-steps.rb b/test/react-native/features/steps/react-native-steps.rb index fbe2012736..396d713b71 100644 --- a/test/react-native/features/steps/react-native-steps.rb +++ b/test/react-native/features/steps/react-native-steps.rb @@ -16,28 +16,42 @@ } end -Then('the app is not running') do - Maze::Wait.new(interval: 1, timeout: 10).until do - case Maze::Helper.get_current_platform - when 'ios' - state = Maze.driver.app_state('org.reactjs.native.example.reactnative') - $logger.info "The app is #{state}" - state == :not_running - when 'android' - state = Maze.driver.app_state('com.reactnative') - $logger.info "The app is #{state}" - # workaround for faulty app state detection in appium v1.23 and lower on - # Android where an app that is not running is detected to be running in - # the background - state == :not_running || state == :running_in_background - end +# Waits for up to 10 seconds for the app to stop running. It seems that Appium doesn't always +# get the state correct (e.g. when backgrounding the app, or on old Android versions), so we +# don't fail if it still says running after the time allowed. +def wait_for_app_state(expected_state) + max_attempts = 20 + attempts = 0 + state = get_app_state + until (attempts >= max_attempts) || state == expected_state + attempts += 1 + state = get_app_state + sleep 0.5 + end + $logger.warn "App state #{state} instead of #{expected_state} after 10s" unless state == expected_state + state +end + +def get_app_state + case Maze::Helper.get_current_platform + when 'ios' + Maze.driver.app_state('org.reactjs.native.example.reactnative') + when 'android' + Maze.driver.app_state('com.reactnative') end end When('I relaunch the app after a crash') do - # Wait for the app to stop running before relaunching - step 'the app is not running' + state = wait_for_app_state :not_running + # TODO: Really we should be using terminate_app/activate_app with the newer Appium client, + # but for some reason they seem to make some scenarios flaky (presumably due to the + # nature of how/when they close the app). + if state != :not_running + Maze.driver.close_app + # Maze.driver.terminate_app Maze.driver.app_id + end Maze.driver.launch_app + # Maze.driver.activate_app Maze.driver.app_id end When('I clear any error dialogue') do diff --git a/test/react-native/features/support/env.rb b/test/react-native/features/support/env.rb index 7371769628..b86a0347da 100644 --- a/test/react-native/features/support/env.rb +++ b/test/react-native/features/support/env.rb @@ -3,12 +3,17 @@ Maze.config.receive_requests_wait = 30 end -Before('@android_only') do |scenario| - skip_this_scenario("Skipping scenario") if Maze.driver.capabilities["os"].eql?('ios') +Before do + # See https://www.browserstack.com/docs/app-automate/appium/troubleshooting/app-orientation-issues + Maze.driver.set_rotation(:portrait) end -Before('@ios_only') do |scenario| - skip_this_scenario("Skipping scenario") if Maze.driver.capabilities["os"].eql?('android') +Before('@android_only') do |_scenario| + skip_this_scenario("Skipping scenario") unless Maze::Helper.get_current_platform == 'android' +end + +Before('@ios_only') do |_scenario| + skip_this_scenario("Skipping scenario") unless Maze::Helper.get_current_platform == 'ios' end Before('@navigation') do |scenario|