You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the Patrol testing framework, text input fails in a text field that has the autofocus property set to true. The first text field without autofocus behaves as expected, but any subsequent field with autofocus enabled does not receive text input.
Steps to Reproduce
1. Create a simple Flutter app with two text fields.
• The first field does not have autofocus.
• The second field has autofocus: true.
2. Write a test to enter text into both fields sequentially using Patrol.
3. Observe that the second field does not receive the input.
Expected Behavior
Patrol should enter text into the second text field, regardless of the autofocus setting.
Test File
Below is the relevant test file:
import'package:flutter/material.dart';
import'package:flutter_test/flutter_test.dart';
import'package:patrol/patrol.dart';
import'package:patrol_invisible_textfield_bug/main.dart';
voidmain() {
patrolTest(
'Complete flow test - username to welcome page',
framePolicy:LiveTestWidgetsFlutterBindingFramePolicy.fullyLive,
($) async {
// Start the appawait $.pumpWidget(constMyApp());
// Enter username and tap nextawait $(Key('username_text_field')).enterText('test');
await $(Key('username_next_button')).tap();
// Enter password and tap nextawait $(Key('password_text_field')).enterText('123456');
await $(Key('password_next_button')).tap();
// Verify we're on the welcome page with correct usernameexpect(
$(Key('welcome_text')).text,
'test',
reason:'Welcome page should display the entered username',
);
},
);
}
Additional Notes
A repo with example code can be found here. Note that only iOS project is fully configured to run the tests.
Actual results
Text is not entered into the second field with autofocus: true.
Logs
Logs
Verbose mode enabled. More logs will be printed.
Received 1 test target(s)
Received test target: /Users/user/workspace/temp/patrol_invisible_textfield_bug/integration_test/app_test.dart
Generated entrypoint /Users/user/workspace/temp/patrol_invisible_textfield_bug/integration_test/test_bundle.dart with 1 bundled test(s)
$ flutter --no-version-check --suppress-analytics devices --machine
Received 1 device(s) to run on
Received device: iPhone 16 Pro Max
$ flutter --suppress-analytics --no-version-check pub deps --style=list
Received 6 --dart-define(s) (0 custom, 6 internal)
Received internal --dart-define: PATROL_WAIT=0
Received internal --dart-define: INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false
Received internal --dart-define: PATROL_TEST_LABEL_ENABLED=true
Received internal --dart-define: PATROL_TEST_SERVER_PORT=8081
Received internal --dart-define: PATROL_APP_SERVER_PORT=8082
Received internal --dart-define: COVERAGE_ENABLED=false
• Building app with entrypoint test_bundle.dart for iOS simulator (debug)...
$ flutter build ios --no-version-check --suppress-analytics --config-only --no-codesign --debug --simulator --target /Users/user/workspace/temp/patrol_invisible_textfield_bug/integration_test/test_bundle.dart --dart-define PATROL_WAIT=0 --dart-define INTEGRATION_TEST_SHOULD_REPORT_RESULTS_TO_NATIVE=false --dart-define PATROL_TEST_LABEL_ENABLED=true --dart-define PATROL_TEST_SERVER_PORT=8081 --dart-define PATROL_APP_SERVER_PORT=8082 --dart-define COVERAGE_ENABLED=false
Building com.example.patrolInvisibleTextfieldBug for simulator (ios)...
$ xcodebuild build-for-testing -workspace Runner.xcworkspace -scheme Runner -configuration Debug -sdk iphonesimulator -destination generic/platform=iOS Simulator -quiet -derivedDataPath ../build/ios_integ OTHER_SWIFT_FLAGS=$(inherited) -D PATROL_ENABLED
/Users/user/workspace/temp/patrol_invisible_textfield_bug/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 12.0 to 18.2.99. (in target 'CocoaAsyncSocket' from project 'Pods')
/Users/user/workspace/temp/patrol_invisible_textfield_bug/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 18.2.99. (in target 'patrol-patrol_privacy' from project 'Pods')
note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner')
warning: Run script build phase 'xcode_backend build' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'RunnerUITests' from project 'Runner')
warning: Run script build phase 'xcode_backend embed_and_thin' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'RunnerUITests' from project 'Runner')
✓ Completed building app with entrypoint test_bundle.dart for iOS simulator (23.8s)
Will uninstall apps before running tests
$ log stream
• Running app with entrypoint test_bundle.dart for iOS simulator on simulator iPhone 16 Pro Max...
$ xcodebuild -showsdks -json
Assuming SDK version 18.2 for iphonesimulator
Looking for .xctestrun matching Runner_*iphonesimulator18.2*.xctestrun at /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_integ/Build/Products
Found 1 match(es), the first one will be used
Found /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_integ/Build/Products/Runner_iphonesimulator18.2-arm64-x86_64.xctestrun
$ xcodebuild test-without-building -xctestrun /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_integ/Build/Products/Runner_iphonesimulator18.2-arm64-x86_64.xctestrun -only-testing RunnerUITests/RunnerUITests -destination platform=iOS Simulator,name=iPhone 16 Pro Max -destination-timeout 1 -resultBundlePath /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild test-without-building -xctestrun /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_integ/Build/Products/Runner_iphonesimulator18.2-arm64-x86_64.xctestrun -only-testing RunnerUITests/RunnerUITests -destination "platform=iOS Simulator,name=iPhone 16 Pro Max" -destination-timeout 1 -resultBundlePath /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
User defaults from command line:
IDEBuildOperationResultBundlePath = /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
IDEPackageSupportUseBuiltinSCM = YES
Writing result bundle at path:
/Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:F3B2309E-66DC-459E-A616-6FB7CF2BA3B9, OS:18.2, name:iPhone 16 Pro Max }
{ platform:iOS Simulator, id:F3B2309E-66DC-459E-A616-6FB7CF2BA3B9, OS:18.2, name:iPhone 16 Pro Max }
2025-01-21 16:32:30.424468+0000 RunnerUITests-Runner[42611:4078572] [Default] Running tests...
2025-01-21 16:32:31.880870+0000 RunnerUITests-Runner[42611:4078572] Running tests without clearing permissions
2025-01-21 16:32:31.882385+0000 RunnerUITests-Runner[42611:4078572] PatrolServer: INFO: PatrolServer constructor called
2025-01-21 16:32:31.882444+0000 RunnerUITests-Runner[42611:4078572] PatrolServer: INFO: PATROL_ENABLED flag is defined
2025-01-21 16:32:31.890189+0000 RunnerUITests-Runner[42611:4078572] PatrolServer: INFO: Starting server...
2025-01-21 16:32:31.893001+0000 RunnerUITests-Runner[42611:4078572] PatrolServer: INFO: Server started on http://0.0.0.0:8081
2025-01-21 16:32:31.893148+0000 RunnerUITests-Runner[42611:4078572] PatrolAppServiceClient: created, port: 8082
t = nans Checking existence of `"Allow" Button`
t = nans Ignoring failure to get hierarchy for remote element in process 32670 (Error getting main window kAXErrorServerNotFound)
t = nans Ignoring failure to get hierarchy for remote element in process 32670 (Error getting main window kAXErrorServerNotFound)
t = nans Open com.example.patrolInvisibleTextfieldBug
t = nans Launch com.example.patrolInvisibleTextfieldBug
t = nans Setting up automation session
t = nans Wait for com.example.patrolInvisibleTextfieldBug to idle
2025-01-21 16:32:33.462888+0000 RunnerUITests-Runner[42611:4078713] PatrolServer: INFO: App reported that it is ready
2025-01-21 16:32:34.167966+0000 RunnerUITests-Runner[42611:4078572] PatrolAppServiceClient.listDartTests()
2025-01-21 16:32:34.202620+0000 RunnerUITests-Runner[42611:4078703] [connection] nw_socket_handle_socket_event [C1.1.1:2] Socket SO_ERROR [61: Connection refused]
2025-01-21 16:32:34.202754+0000 RunnerUITests-Runner[42611:4078703] [connection] nw_endpoint_flow_failed_with_error [C1.1.1 ::1.8082 in_progress socket-flow (satisfied (Path is satisfied), interface: lo0)] already failing, returning
2025-01-21 16:32:34.221036+0000 RunnerUITests-Runner[42611:4078703] PatrolAppServiceClient.listDartTests(): succeeded
2025-01-21 16:32:35.179472+0000 RunnerUITests-Runner[42611:4078572] Got 1 Dart tests: (
{
name = "app_test Complete flow test - username to welcome page";
skip = 0;
}
)
2025-01-21 16:32:35.179670+0000 RunnerUITests-Runner[42611:4078572] RunnerUITests.testInvocations(): selectorName = app_test Complete flow test - username to welcome page, signature: <NSMethodSignature: 0x8d7d0cd5bf411faf>
Test Suite 'Selected tests' started at 2025-01-21 16:32:35.189.
Test Suite 'RunnerUITests.xctest' started at 2025-01-21 16:32:35.189.
Test Suite 'RunnerUITests' started at 2025-01-21 16:32:35.189.
Test Case '-[RunnerUITests app_test Complete flow test - username to welcome page]' started.
t = 0.00s Start Test at 2025-01-21 16:32:35.190
t = 0.03s Set Up
t = 0.03s Open com.example.patrolInvisibleTextfieldBug
t = 0.03s Launch com.example.patrolInvisibleTextfieldBug
t = 0.03s Terminate com.example.patrolInvisibleTextfieldBug:42623
t = 1.30s Setting up automation session
t = 1.73s Wait for com.example.patrolInvisibleTextfieldBug to idle
2025-01-21 16:32:37.244626+0000 RunnerUITests-Runner[42611:4078707] PatrolServer: INFO: App reported that it is ready
2025-01-21 16:32:39.057279+0000 RunnerUITests-Runner[42611:4078572] PatrolAppServiceClient.runDartTest(app_test Complete flow test - username to welcome page)
2025-01-21 16:32:39.071276+0000 RunnerUITests-Runner[42611:4078688] [connection] nw_socket_handle_socket_event [C2.1.1:2] Socket SO_ERROR [61: Connection refused]
2025-01-21 16:32:39.071438+0000 RunnerUITests-Runner[42611:4078688] [connection] nw_endpoint_flow_failed_with_error [C2.1.1 ::1.8082 in_progress socket-flow (satisfied (Path is satisfied), interface: lo0)] already failing, returning
🧪 Complete flow test - username to welcome page
⏳ 1. �[35menterText�[0m widgets with key [<'username_text_field'>].
�[A�[K ✅ 1. �[35menterText�[0m widgets with key [<'username_text_field'>].
⏳ 2. �[33mtap�[0m widgets with key [<'username_next_button'>].
�[A�[K ✅ 2. �[33mtap�[0m widgets with key [<'username_next_button'>].
⏳ 3. �[35menterText�[0m widgets with key [<'password_text_field'>].
�[A�[K ✅ 3. �[35menterText�[0m widgets with key [<'password_text_field'>].
⏳ 4. �[33mtap�[0m widgets with key [<'password_next_button'>].
�[A�[K ✅ 4. �[33mtap�[0m widgets with key [<'password_next_button'>].
❌ Complete flow test - username to welcome page �[30m(integration_test/app_test.dart)�[0m �[30m(32s)�[0m
�[31m══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════�[0m
�[31mThe following PatrolFinderException was thrown running a test:�[0m
�[31mFinder "Found 0 widgets with key [<'welcome_text'>]: []" found no�[0m
�[31mwidgets�[0m
�[31m�[0m
�[31mWhen the exception was thrown, this was the stack:�[0m
�[31m#0 PatrolFinder.text (package:patrol_finders/src/custom_finders/patrol_finder.dart:467:7)�[0m
�[31m#1 main.<anonymous closure> (file:///Users/user/workspace/temp/patrol_invisible_textfield_bug/integration_test/app_test.dart:24:32)�[0m
�[31m<asynchronous suspension>�[0m
�[31m#2 patrolTest.<anonymous closure> (package:patrol/src/common.dart:150:7)�[0m
�[31m<asynchronous suspension>�[0m
�[31m#3 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)�[0m
�[31m<asynchronous suspension>�[0m
�[31m#4 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1027:5)�[0m
�[31m<asynchronous suspension>�[0m
�[31m#5 TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:824:12)�[0m
�[31m<asynchronous suspension>�[0m
�[31m�[0m
�[31mThe test description was:�[0m
�[31m Complete flow test - username to welcome page�[0m
�[31m═════════════════════════════════════════════════════════════════�[0m
�[31m�[0m
2025-01-21 16:33:11.362978+0000 RunnerUITests-Runner[42611:4078689] runDartTest("app_test Complete flow test - username to welcome page"): call finished, test result: FAILED
/Users/user/workspace/temp/patrol_invisible_textfield_bug/ios/RunnerUITests/RunnerUITests.m:5: error: -[RunnerUITests app_test Complete flow test - username to welcome page] : ((passed) is true) failed - ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following PatrolFinderException was thrown running a test:
Finder "Found 0 widgets with key [<'welcome_text'>]: []" found no
widgets
When the exception was thrown, this was the stack:
#0 PatrolFinder.text (package:patrol_finders/src/custom_finders/patrol_finder.dart:467:7)
#1 main.<anonymous closure> (file:///Users/user/workspace/temp/patrol_invisible_textfield_bug/integration_test/app_test.dart:24:32)
<asynchronous suspension>
#2 patrolTest.<anonymous closure> (package:patrol/src/common.dart:150:7)
<asynchronous suspension>
#3 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#4 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1027:5)
<asynchronous suspension>
#5 TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:824:12)
<asynchronous suspension>
The test description was:
Complete flow test - username to welcome page
═════════════════════════════════════════════════════════════════
t = 37.03s Tear Down
Test Case '-[RunnerUITests app_test Complete flow test - username to welcome page]' failed (37.552 seconds).
Test Suite 'RunnerUITests' failed at 2025-01-21 16:33:12.741.
Executed 1 test, with 1 failure (0 unexpected) in 37.552 (37.552) seconds
Test Suite 'RunnerUITests.xctest' failed at 2025-01-21 16:33:12.741.
Executed 1 test, with 1 failure (0 unexpected) in 37.552 (37.552) seconds
Test Suite 'Selected tests' failed at 2025-01-21 16:33:12.742.
Executed 1 test, with 1 failure (0 unexpected) in 37.552 (37.553) seconds
2025-01-21 16:33:29.533 xcodebuild[42607:4078329] [MT] IDETestOperationsObserverDebug: 60.341 elapsed -- Testing started completed.
2025-01-21 16:33:29.533 xcodebuild[42607:4078329] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2025-01-21 16:33:29.533 xcodebuild[42607:4078329] [MT] IDETestOperationsObserverDebug: 60.341 sec, +60.341 sec -- end
Test session results, code coverage, and logs:
/Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
Failing tests:
-[RunnerUITests app_test Complete flow test - username to welcome page]
** TEST EXECUTE FAILED **
Testing started
�[1mTest summary:�[0m
📝 Total: 1
✅ Successful: 0
❌ Failed: 1
- Complete flow test - username to welcome page �[30m(integration_test/app_test.dart)�[0m
⏩ Skipped: 0
📊 Report: /Users/user/workspace/temp/patrol_invisible_textfield_bug/build/ios_results_1737477148092.xcresult
⏱️ Duration: 63s
✗ Failed to execute tests of app with entrypoint test_bundle.dart for iOS simulator on simulator iPhone 16 Pro Max (xcodebuild exited with code 65) (63.4s)
#0 throwToolExit (package:patrol_cli/src/base/exceptions.dart:7:3)
#1 IOSTestBackend.execute.<anonymous closure> (package:patrol_cli/src/ios/ios_test_backend.dart:233:9)
<asynchronous suspension>
#2 DisposeScope.run (package:dispose_scope/src/dispose_scope.dart:46:7)
<asynchronous suspension>
#3 IOSTestBackend.execute (package:patrol_cli/src/ios/ios_test_backend.dart:160:5)
<asynchronous suspension>
#4 TestCommand._execute (package:patrol_cli/src/commands/test.dart:392:7)
<asynchronous suspension>
#5 TestCommand.run (package:patrol_cli/src/commands/test.dart:265:23)
<asynchronous suspension>
#6 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#7 PatrolCommandRunner.runCommand (package:patrol_cli/src/runner/patrol_command_runner.dart:384:18)
<asynchronous suspension>
#8 PatrolCommandRunner.run (package:patrol_cli/src/runner/patrol_command_runner.dart:328:18)
<asynchronous suspension>
#9 patrolCommandRunner (package:patrol_cli/src/runner/patrol_command_runner.dart:75:20)
<asynchronous suspension>
#10 main (file:///Users/user/.pub-cache/hosted/pub.dev/patrol_cli-3.5.0/bin/main.dart:6:20)
<asynchronous suspension>
Patrol version
patrol: ^3.14.0
patrol_finders: ^2.7.0
Patrol Doctor output
Patrol Doctor output
Patrol doctor:
Patrol CLI version: 3.5.0
Flutter command: flutter
Flutter 3.27.2 • channel stable
Android:
• Program adb found in /opt/homebrew/bin/adb
• Env var $ANDROID_HOME set to /Users/daniilshumko/Library/Android/sdk
iOS / macOS:
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
Flutter Doctor output
Flutter Doctor output
➜ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.2, on macOS 15.2 24C101 darwin-arm64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.4)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!
The text was updated successfully, but these errors were encountered:
Steps to reproduce
When using the Patrol testing framework, text input fails in a text field that has the autofocus property set to true. The first text field without autofocus behaves as expected, but any subsequent field with autofocus enabled does not receive text input.
Steps to Reproduce
1. Create a simple Flutter app with two text fields.
• The first field does not have autofocus.
• The second field has autofocus: true.
2. Write a test to enter text into both fields sequentially using Patrol.
3. Observe that the second field does not receive the input.
Expected Behavior
Patrol should enter text into the second text field, regardless of the autofocus setting.
Test File
Below is the relevant test file:
Example App Code
The following code demonstrates the issue:
Environment
Additional Notes
A repo with example code can be found here. Note that only iOS project is fully configured to run the tests.
Actual results
Text is not entered into the second field with autofocus: true.
Logs
Logs
Patrol version
patrol: ^3.14.0
patrol_finders: ^2.7.0
Patrol Doctor output
Patrol Doctor output
Flutter Doctor output
Flutter Doctor output
The text was updated successfully, but these errors were encountered: