leancodepl / patrol

Flutter-first UI testing framework. Ready for action!
https://patrol.leancode.co
Apache License 2.0
848 stars 125 forks source link

Truncated text is not identified by patrol #2260

Closed karthiga812 closed 1 month ago

karthiga812 commented 1 month ago

Steps to reproduce

I've got a text as title for y ListTile. This text has overflow set to ellipsis. In my integration test I'm testing this text with expect($('My very long text is displayed here'), findsOneWidget); and it fails to identify the widget. I'm running my test on my Android device. On the device, because of the screen size, this text is truncated and displayed as 'My very long test is dis...'. How to test this text?

Actual results

I'm running my test on my Android device. On the device, because of the screen size, this text is truncated and displayed as 'My very long test is dis...'. The test fails saying 'Expected: exactly one matching candidate Actual: _TextWidgetFinder:<Found 0 widgets with text "My very long text is displayed here": []> Which: means none were found but one was expected'

Logs

Logs ``` ```

Patrol version

^3.9.0

Patrol Doctor output

Patrol Doctor output ``` Patrol doctor: Patrol CLI version: 2.8.1 Flutter command: flutter Flutter 3.22.2 • channel stable Android: • Program adb found in C:\Users\{username}\AppData\Local\Android\Sdk\platform-tools\adb.exe • Env var $ANDROID_HOME set to C:\Users\{username}n\AppData\Local\Android\Sdk ```

Flutter Doctor output

Flutter Doctor output ``` [√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.22631.3737], locale en-GB) • Flutter version 3.22.2 on channel stable at C:\Users\Public\Flutter\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\{username}\AppData\Local\Android\Sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = C:\Users\{username}\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.10.2) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Professional • Visual Studio Professional 2022 version 17.10.35004.147 • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874) [√] VS Code (version 1.91.0) • VS Code at C:\Users\{username}\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.86.0 [√] Connected device (4 available) • SM G973F (mobile) • R58N600PB4N • android-arm64 • Android 12 (API 31) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3737] • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.127 • Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.87 [√] Network resources • All expected network resources are available. • No issues found! ```
zoskar commented 1 month ago

Hi @karthiga812 In my opinion th best way would be to add a Key to the widget and try to find the element by it in the test. If that is not possible (let's say your ListTile is generated from dynamic list of elements) then you could assign the text of the tile to the Key. This way you work around truncated text. Also, I'd say with such questions you will get the best answers if you ask them on Patrol Discrord channel. . That way the whole community will see it and will get a chance to share how they solved similar issues.

github-actions[bot] commented 1 month ago

Without additional information, we can't resolve this issue. We're therefore reluctantly going to close it. Feel free to open a new issue with all the required information provided, including a minimal, reproducible sample. Make sure to diligently fill out the issue template. Thanks for your contribution.

github-actions[bot] commented 1 month ago

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.