selectFineLocation throws on iOS if it's already selected
Closed this issue Β· 4 comments
Steps to reproduce
- Write a test that uses
$.native.selectFineLocation()
(on an app that actually triggers the permission dialog) - Note that the docs for
selectFineLocation
state "Throws if no permission request dialog is present." - Run the test
Actual results
- The permission dialog shows up
- "Precise: On" is already set (by default?)
- Because the function only looks for a button with text "Precise: Off" to toggle it, it throws after timeout :(
Logs
Logs
Parts have been skipped for brevity; the relevant part is still included
Patrol (native): configure() succeeded
Patrol (native): isPermissionDialogVisible() started
2024-04-02 18:36:22.733331+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: checking if permission dialog is visible...
t = nans Checking existence of `"OK" Button`
t = nans Checking existence of `"Allow" Button`
t = nans Checking existence of `"Allow once" Button`
t = nans Checking existence of `"Allow While Using App" Button`
t = nans Checking existence of `"Donβt Allow" Button`
2024-04-02 18:36:23.829000+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: done checking if permission dialog is visible
2024-04-02 18:36:23.830221+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: result: false
Patrol (native): isPermissionDialogVisible() succeeded
Patrol (native): selectFineLocation() started
2024-04-02 18:36:23.838985+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: selecting fine location...
t = nans Waiting 10.0s for "Precise: Off" Button to exist
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
: Syncing files to device iPhone 15 Pro... 8.8s
:
Hot Restart: attached to the app (press "r" to restart)
: Flutter run key commands.
: r Hot reload. π₯π₯π₯
: R Hot restart.
: h List all available interactive commands.
: d Detach (terminate "flutter run" but leave application running).
: c Clear the screen
: q Quit (terminate the application on the device).
:
: A Dart VM Service on iPhone 15 Pro is available at: http://127.0.0.1:58088/4tj4ehFMtZU=/
Patrol DevTools extension is available at http://127.0.0.1:9100/patrol_ext?uri=http://127.0.0.1:58088/4tj4ehFMtZU=/
: The Flutter DevTools debugger and profiler on iPhone 15 Pro is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:58088/4tj4ehFMtZU=/
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing element debug description
t = nans Checking existence of `"Precise: Off" Button`
t = nans Capturing debug information
t = nans Requesting snapshot of accessibility hierarchy for app with pid 18251
2024-04-02 18:36:33.947904+0200 RunnerUITests-Runner[28268:3151843] PatrolServer: ERROR: button to select fine location doesn't exist
Patrol (native): selectFineLocation() failed
βββ‘ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK βββββββββββββββββββββββββββββββββββββββββββββββββββββ
The following PatrolActionException was thrown running a test:
Patrol action failed: NativeAutomatorClientException: selectFineLocation() failed with Invalid
response: 400 The operation couldnΓ’t be completed. (patrol.PatrolError error 0.)
flutter:
When the exception was thrown, this was the stack:
#0 NativeAutomator._wrapRequest (package:patrol/src/native/native_automator.dart:226:7)
<asynchronous suspension>
#1 NativeAutomator.selectFineLocation (package:patrol/src/native/native_automator.dart:838:5)
<asynchronous suspension>
#2 main.<anonymous closure> (file:///Volumes/external/projects/kommunalapp/app/integration_test/maengel_melder_test.dart:39:7)
<asynchronous suspension>
#3 patrolTest.<anonymous closure> (package:patrol/src/common.dart:134:7)
<asynchronous suspension>
#4 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:183:15)
<asynchronous suspension>
#5 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1017:5)
<asynchronous suspension>
#6 TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:808:12)
<asynchronous suspension>
Patrol version
patrol: ^3.6.0
Patrol Doctor output
Patrol Doctor output
Patrol doctor:
Patrol CLI version: 2.7.0
Flutter command: fvm flutter
Flutter 3.19.1 β’ channel stable
Android:
β’ Program adb not found (install with `export PATH="$ANDROID_HOME/platform-tools:$PATH"`)
β’ Env var $ANDROID_HOME is not set. (See the link: https://developer.android.com/tools/variables#set)
iOS / macOS:
β’ Program xcodebuild found in /usr/bin/xcodebuild
β’ Program ideviceinstaller not found (install with `brew install ideviceinstaller`)
Flutter Doctor output
Flutter Doctor output
[β] Flutter (Channel stable, 3.19.1, on macOS 14.4.1 23E224 darwin-arm64, locale en-DE)
β’ Flutter version 3.19.1 on channel stable at /Users/thorstenthiel/fvm/versions/3.19.1
β’ Upstream repository https://github.com/flutter/flutter.git
β’ Framework revision abb292a07e (6 weeks ago), 2024-02-20 14:35:05 -0800
β’ Engine revision 04817c99c9
β’ Dart version 3.3.0
β’ DevTools version 2.31.1
[β] Android toolchain - develop for Android devices
β Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[β] Xcode - develop for iOS and macOS (Xcode 15.2)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Build 15C500b
β’ CocoaPods version 1.15.2
[β] Chrome - develop for the web
β’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (not installed)
β’ Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[β] VS Code (version 1.87.1)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.84.0
[β] Connected device (3 available)
β’ iPhone 15 Pro (mobile) β’ 90B2D2DB-CF8F-4810-9FC5-E8009839343D β’ ios β’ com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
β’ macOS (desktop) β’ macos β’ darwin-arm64 β’ macOS 14.4.1 23E224 darwin-arm64
β’ Chrome (web) β’ chrome β’ web-javascript β’ Google Chrome 123.0.6312.87
[β] Network resources
β’ All expected network resources are available.
! Doctor found issues in 2 categories.
Fwiw, a workaround for the time being is to just wrap a try/catch around the call but it would feel a lot safer if the function more generally "ensured" the setting instead of trying to set it and fail if it's already good to go.
For the record: The same issue (albeit with "On" instead of "Off") is also present for selectCoarseLocation
.
Thanks for reporting that. Using the enableWiFi
method as an example of expected behaviour, we should log 'fine location already selected' instead of throwing an exception. And 'coarse location already selected' for the selectCoarseLocation
method.
Size: S
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.