patrol icon indicating copy to clipboard operation
patrol copied to clipboard

Cannot find text inside native TextField on iOS

Open fylyppo opened this issue 1 year ago • 1 comments

Steps to reproduce

  1. Clone https://github.com/leancodepl/patrol.git and checkout to bug/ios-reproduce-examples
  2. run iOS simulator, open messages and tap on tile to see conversation on the screen and message bottom bar
  3. in patrol/dev/e2e_app run: patrol test -t integration_test/ios_text_field_text_test.dart

Actual results

waitUntilVisible() failed

Logs

Logs
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
        The following PatrolActionException was thrown running a test:
        Patrol action failed: NativeAutomatorClientException: waitUntilVisible() failed with Invalid
        response: 400 The operation couldnât be completed. (patrol.PatrolError error 0.)
        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.waitUntilVisible (package:patrol/src/native/native_automator.dart:693:5)
        <asynchronous suspension>
        #2      main.<anonymous closure> (file:///Users/fylyppo/Documents/GitHub/patrol/dev/e2e_app/integration_test/ios_text_field_text_test.dart:13:7)
        <asynchronous suspension>
        #3      patrolTest.<anonymous closure> (package:patrol/src/common.dart:130:7)
        <asynchronous suspension>
        #4      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:168:15)
        <asynchronous suspension>
        #5      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1013:5)
        <asynchronous suspension>
        #6      TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:804:12)
        <asynchronous suspension>

Patrol version

from branch

Patrol Doctor output

Patrol Doctor output
<!-- Replace this line with your logs. Do not remove the backticks! -->

Flutter Doctor output

Flutter Doctor output
<!-- Replace this line with your logs. Do not remove the backticks! -->

fylyppo avatar Jan 30 '24 20:01 fylyppo

So, I investigated this issue and there are a few problems:

  1. the enterTextByIndex method inserts text into a TextField with newline, causing Selector(text:) without newline to always fail.
  2. Ios TextField keeps the current text in "value" property. However, waitUntilVisible and getNativeViews do not use this property in predicate.
  3. Inspector also uses NativeView model and this model lacks value and placeholderValue.

zltnDC avatar Feb 08 '24 14:02 zltnDC