leancodepl / patrol

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

Only white screen #2284

Closed ioma8 closed 2 months ago

ioma8 commented 2 months ago

Steps to reproduce

Versions: patrol_cli v3.0.1 patrol: 3.9.0

  1. I have done android setup as described in the guide.
  2. I have created simple test:
    
    import 'package:flutter/material.dart';
    import 'package:flutter_test/flutter_test.dart';
    import 'package:patrol/patrol.dart';

void main() { patrolTest( 'counter state is the same after going to home and switching apps', ($) async { await $.pumpWidgetAndSettle( MaterialApp( home: Scaffold( appBar: AppBar(title: const Text('app')), backgroundColor: Colors.blue, ), ), duration: const Duration(seconds: 10), );

  expect($('app'), findsOneWidget);

  await $.native.pressHome();
},

); }

3. I try to run it with patrol test or patrol develop command. I am running it as follows:

patrol develop -t integration_test/experiments/mytest_test.dart


### Actual results

 In patrol develop I get those error messages:
The Dart VM service is listening on http://127.0.0.1:38875/YxB7SRH_J_U=/
Patrol (native): NativeAutomatorClient created, port: 8081
Patrol (native): initialize() started
Patrol (native): initialize() failed

In both patrol test and patrol develop I am getting just white screen in the android emulator:
<img width="386" alt="image" src="https://github.com/user-attachments/assets/2babd8c2-837c-476b-913f-34bddc5a8a4c">

Interesting thing is when my colleagues run the same command in the same codebase, it runs the tests for them.

### Logs

<details>
<summary>Logs</summary>

</details>

### Patrol version

patrol: 3.9.0

### Patrol Doctor output

<details>
<summary>Patrol Doctor output</summary>

Patrol doctor: Patrol CLI version: 3.0.1 Flutter command: flutter Flutter 3.22.2 • channel stable Android: • Program adb found in /Users/myaccount/Library/Android/sdk/platform-tools/adb • Env var $ANDROID_HOME set to /Users/myaccount/Library/Android/sdk iOS / macOS: • Program xcodebuild found in /usr/bin/xcodebuild • Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller


</details>

### Flutter Doctor output

<details>
<summary>Flutter Doctor output</summary>

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale cs-CZ) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.4) [✓] Chrome - develop for the web [✓] Android Studio (version 2024.1) [✓] IntelliJ IDEA Ultimate Edition (version 2024.1.4) [✓] VS Code (version 1.91.1) [✓] Connected device (4 available) ! Error: Browsing on the local area network for Dušan - iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources

• No issues found!



</details>
ioma8 commented 2 months ago

I am also attaching the errors from the "--verbose" output as it provides more information (still for me not useful as I was unable to resolve it).

        Patrol (native): NativeAutomatorClient created, port: 8081
        Patrol (native): initialize() started
        Patrol (native): initialize() failed
        E/flutter ( 5080): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ClientException with SocketException: Failed host lookup: 'localhost' (OS Error: No address associated with hostname, errno = 7), uri=http://localhost:8081/initialize
        E/flutter ( 5080): #0      IOClient.send (package:http/src/io_client.dart:154:7)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #2      Future.timeout.<anonymous closure> (dart:async/future_impl.dart:949:15)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #3      NativeAutomatorClient._sendRequest (package:patrol/src/native/contracts/native_automator_client.dart:341:22)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #4      NativeAutomator._wrapRequest (package:patrol/src/native/native_automator.dart:219:22)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #5      NativeAutomator.initialize (package:patrol/src/native/native_automator.dart:243:5)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): #6      main (file:///Users/jakubkolcar/projects-rnt/raynetcrm_mobile_app/integration_test/test_bundle.dart:13:3)
        E/flutter ( 5080): <asynchronous suspension>
        E/flutter ( 5080): 
        : Syncing files to device sdk gphone64 arm64...                       5,1s
        : 
ioma8 commented 2 months ago

Okay what fixed it after two days of debugging and trying to update SDKs etc, was wiping the android emulator. I still do not know what was the problem, but wiping the virtual device fixed it. I am writing it for future people who would encounter the same issue.

Kendru98 commented 1 month ago

Hi, I'm glad that issue was solved by itself. If you have another not known issues that look more that something is wrong with simulator or config, don't hesitate to join our discord and ask community & our moderators. https://discord.com/invite/ukBK5t4EZg

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.