appium / appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
MIT License
451 stars 183 forks source link

Allow appium-flutter-driver start an app process via 3rd paty tool #433

Closed KazuCocoa closed 1 year ago

KazuCocoa commented 1 year ago

https://github.com/appium-userland/appium-flutter-driver/issues/115#issuecomment-1467549554


Theoretically, it could. Appium XCUITest driver launches the app under test via XCTest API to follow how iOS launches the app as a black-box testing tool.

Maybe there are two options. Adding the possibility in https://github.com/appium/appium-ios-device, or use https://github.com/ios-control/ios-deploy or other tools like https://github.com/danielpaulus/go-ios to launch the app with a debugger for this driver specific. The appium-ios-device already has an ability to launch an app process via instrument, so potentially it could achieve with a few changes, or it needs more implementation.

By using an existing method, you also could manage the starting app part on your test code and gives the observatory URL with appium:observatoryWsUri capability. Then, this driver attempts to attach the websocekt against the given URL. In this case, you also could launch the app under test with flutter command as same.

Ernst-D commented 1 year ago

Hey!

So the idea is to run the flutter app via its bundled tools from another process, grab the necessary urls for connection and pass to the driver?

Like the "utility to spawn process -> process runs flutter command -> process also starts flutter-driver", right?

KazuCocoa commented 1 year ago

Yes, when you do outside appium-flutter-driver as By using an existing method way.

This driver package itself can start the application under test process around https://github.com/appium-userland/appium-flutter-driver/blob/main/driver/lib/sessions/ios.ts#L29 instead of xcuitest driver in Appium. Then, it also needs to consider activateApp method's case as well.

Ernst-D commented 1 year ago

hey @KazuCocoa! Is there any documentation about how to contribute into this driver? I would like to try to implement this feature, but first of all I'd like to figure out how to make this driver work for debug purposes

KazuCocoa commented 1 year ago

https://appium.github.io/appium/docs/en/2.0/ecosystem/build-drivers/ might help to catch up with dev environment in Appium 2. The easiest way is build https://github.com/appium-userland/appium-flutter-driver/blob/main/driver/package.json (npm install for example) and copy the build directory into ~/.appium/node_modules/appium-flutter-driver/.

KazuCocoa commented 1 year ago

it seems like Flutter will use xcdebug to start a debug session.

Perhaps... then flutter:connectObservatoryWsUrl way may help...? (since at least short term, 3rd party tooks won't work ios 17 x Xcode 15)

Ernst-D commented 1 year ago

Could you please tell what will be an issue with iOS 17?

KazuCocoa commented 1 year ago

https://github.com/appium/appium/issues/18749 Launching an app via 3rd party tool may fail as com.apple.testmanagerd.lockdown.secure

KazuCocoa commented 1 year ago

driver.execute_script 'flutter:connectObservatoryWsUrl' should help for this. So:

  1. start a session witout app nor bundleId/appPackage
  2. Start driver.execute_script 'flutter:connectObservatoryWsUrl'
  3. Start the app via 3rd party tools

Then, if the 2) detect the observatory url, it will establish a session

https://github.com/appium-userland/appium-flutter-driver#several-ways-to-start-an-application