From ddee2460b5dd3d3a62e5650d23de17a9a1223823 Mon Sep 17 00:00:00 2001 From: Edgars Eglitis Date: Wed, 31 Jan 2024 17:10:40 +0200 Subject: [PATCH 1/3] fix: remove app management methods without app ID --- lib/core/device.rb | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/core/device.rb b/lib/core/device.rb index c7da1457..c1de9587 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -252,15 +252,12 @@ def close_app(action = nil) # Accepts: # Value (optional) def launch_app(action) + raise "Application identifier is required!" unless action.key?("Value") app_id = action["Value"] - if app_id - if @platform == "iOS" - @driver.execute_script('mobile: launchApp', {'bundleId': app_id}) - elsif @platform == "Android" - @driver.activate_app(app_id) - end - else - @driver.launch_app + if @platform == "iOS" + @driver.execute_script('mobile: launchApp', {'bundleId': app_id}) + elsif @platform == "Android" + @driver.execute_script('mobile: activateApp', {'appId': app_id}) end end @@ -269,15 +266,12 @@ def launch_app(action) # Accepts: # Value (optional) def terminate_app(action) + raise "Application identifier is required!" unless action.key?("Value") app_id = action["Value"] - if app_id - if @platform == "iOS" - @driver.execute_script('mobile: terminateApp', {'bundleId': app_id}) - elsif @platform == "Android" - @driver.terminate_app(app_id) - end - else - @driver.close_app + if @platform == "iOS" + @driver.execute_script('mobile: terminateApp', {'bundleId': app_id}) + elsif @platform == "Android" + @driver.execute_script('mobile: terminateApp', {'appId': app_id}) end end From 4921a1b710c81cb33deecd8ecead8bc8fe9b6180 Mon Sep 17 00:00:00 2001 From: Edgars Eglitis Date: Wed, 31 Jan 2024 17:12:31 +0200 Subject: [PATCH 2/3] docs: update docs for previous change --- README.md | 4 ++-- lib/core/device.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4e29a30..18c1aaf5 100644 --- a/README.md +++ b/README.md @@ -695,13 +695,13 @@ Closes the app and leaves it running in the background. - Type: launch_app Role: role1 - Value: com.android.vending (Optional - Android app package / iOS bundle ID) + Value: com.android.vending (Android app package / iOS bundle ID) ### terminate_app - Type: terminate_app Role: role1 - Value: com.apple.Preferences (Optional - Android app package / iOS bundle ID) + Value: com.apple.Preferences (Android app package / iOS bundle ID) ### start_record/end_record (Mobile) diff --git a/lib/core/device.rb b/lib/core/device.rb index c1de9587..a8970829 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -250,7 +250,7 @@ def close_app(action = nil) # launches the app specified by the Android app package / iOS bundle ID # defaults to the app under test if Value is not provided # Accepts: - # Value (optional) + # Value def launch_app(action) raise "Application identifier is required!" unless action.key?("Value") app_id = action["Value"] @@ -264,7 +264,7 @@ def launch_app(action) # closes the app specified by the Android app package / iOS bundle ID # defaults to the app under test if Value is not provided # Accepts: - # Value (optional) + # Value def terminate_app(action) raise "Application identifier is required!" unless action.key?("Value") app_id = action["Value"] From 063946cd6405c41edba2932c81388bd97297308d Mon Sep 17 00:00:00 2001 From: Edgars Eglitis Date: Thu, 1 Feb 2024 15:40:35 +0200 Subject: [PATCH 3/3] fix: address review comments --- lib/core/device.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/device.rb b/lib/core/device.rb index a8970829..fba1c171 100644 --- a/lib/core/device.rb +++ b/lib/core/device.rb @@ -252,7 +252,7 @@ def close_app(action = nil) # Accepts: # Value def launch_app(action) - raise "Application identifier is required!" unless action.key?("Value") + raise "Please specify the application identifier in the Value field!" unless action.key?("Value") app_id = action["Value"] if @platform == "iOS" @driver.execute_script('mobile: launchApp', {'bundleId': app_id}) @@ -266,7 +266,7 @@ def launch_app(action) # Accepts: # Value def terminate_app(action) - raise "Application identifier is required!" unless action.key?("Value") + raise "Please specify the application identifier in the Value field!" unless action.key?("Value") app_id = action["Value"] if @platform == "iOS" @driver.execute_script('mobile: terminateApp', {'bundleId': app_id})