AppiumTestDistribution / appium-flutter-integration-driver

MIT License
32 stars 10 forks source link

Unable to test on real device due to port issue #102

Open suryak-cs opened 4 days ago

suryak-cs commented 4 days ago

I have the flutter app with all the necessary configuration such as integration_test/appium_test.dart file. When I built and run the app using the following command flutter run ios --target integration_test/appium_test.dart --flavor qa --release I see the following lines in the terminal

flutter: [APPIUM FLUTTER]  Appium flutter server is listening on port 9000
flutter: 00:00 +0: appium flutter server

So far so good.

And in my automation script in the desired caps, I have also made sure to use "appium:flutterSystemPort", 9001

When I run the test, I see 9001 port number is NOT reachable. See the logs below.

[5211e896][AppiumFlutterDriver@d4bb] Checking if flutter server is running on port 9001
[5211e896][WD Proxy] Matched '/status' to command name 'getStatus'
[5211e896][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9001/status] with no body
[5211e896][iProxy@00008030:9001] Connection was refused to port 9001
[5211e896][WD Proxy] socket hang up
[5211e896][AppiumFlutterDriver@d4bb] FlutterServer not reachable on port 9001, Retrying..
[5211e896][WD Proxy] Matched '/status' to command name 'getStatus'
[5211e896][WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:9001/status] with no body
[5211e896][iProxy@00008030:9001] Connection was refused to port 9001
[5211e896][WD Proxy] socket hang up

It keeps on scanning for next port numbers like 9002, 9003 etc but to no avail.

My dev code has

dev_dependencies:
  appium_flutter_server: 0.0.27

and I am using latest version of appium v2.12.1, Java client is 9.3.0 and flutter integration version flutter-integration@1.1.3 (automationName 'FlutterIntegration').

What's wrong with my setup?

To the contrary if I clone appium-flutter-server repo and change the file server.dart, line # 39 to const PORT_RANGE = [9001, 9020]; and have the server location referred in pubsec.yaml as

  appium_flutter_server:
    path: ../server

127.0.0.1:9001 is reachable and rest everything works fine.

This is just the workaround.

Please let me know the ideal fix for this situation. Thanks!