Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter support for Appium #12919

Closed
truongsinh opened this issue Jul 16, 2019 · 31 comments
Closed

Flutter support for Appium #12919

truongsinh opened this issue Jul 16, 2019 · 31 comments

Comments

@truongsinh
Copy link
Contributor

truongsinh commented Jul 16, 2019

Update

Prototype available at https://www.npmjs.com/package/appium-flutter-driver but we need support from appium declaration first.

The problem

Flutter goes with flutter drive, the e2e test tool, but it does not work with app that has both flutter view and native view (such as embedding Flutter to existing app), or flutter view with web view (open a webview in Flutter).

Having appium flutter driver would solve both problems above, similar to http://appium.io/docs/en/writing-running-appium/web/hybrid/

Related issues:

@umutuzgur
Copy link
Member

umutuzgur commented Jul 16, 2019

Hi @truongsinh. That is a really nice idea but I don't think we have that many resources at the moment. Have you contacted the Flutter team to integrate their driver with the Appium project? There are already some drivers which are developed externally from the Appium team but integrated into the Appium project

@truongsinh
Copy link
Contributor Author

@umutuzgur I created flutter/flutter#36259 . Meanwhile, can you show me to some documentation to get started with developing 3rd party Appium driver, and also some examples?

@truongsinh
Copy link
Contributor Author

related threads: google/EarlGrey#778, flutter/flutter#32987

@truongsinh
Copy link
Contributor Author

related threads: flutter/flutter#25465

@truongsinh truongsinh changed the title Flutter support Flutter support for Appium Jul 16, 2019
@umutuzgur
Copy link
Member

@truongsinh I will ask around where the documentation is for the custom drivers but in the mean time, these are some of the custom drivers appium-youiengine-driver, appium-tizen-driver

@mykola-mokhnach
Copy link
Collaborator

Linking flutter/flutter#17988

@KazuCocoa
Copy link
Member

linking flutter/flutter#32062 (comment)
Espresso->Flutter like Espresso->Web

@truongsinh
Copy link
Contributor Author

@umutuzgur one more question, does the driver have to be in JS, or it can be in other languages?

@umutuzgur
Copy link
Member

umutuzgur commented Jul 18, 2019

@truongsinh It should be JS. I don't know if you can transpile Dart to JS but that would also work I think

@truongsinh
Copy link
Contributor Author

@umutuzgur https://www.npmjs.com/package/appium-flutter-driver first prototype, working with both iOS and Android with limited commands (get text and tap only). But we need to declare this package in appium source code.

@KazuCocoa
Copy link
Member

KazuCocoa commented Jul 21, 2019

Awesome, @truongsinh

It's out of my curiosity.
Do you have any idea about which is better to communicate with DartVM directly or launch an http server for flutter_driver on app like this and communicate with it like appium-uiautomator2-driver/uiautomator2-server, xcuitest-driver/WebDriverAgent and espresso-driver/espresso-server?

Because flutter_driver has knowledge for flutter like https://github.com/flutter/flutter/blob/b712a172f9694745f50505c93340883493b505e5/packages/flutter_driver/lib/src/driver/driver.dart#L770-L821 and getRenderTree()

I considered which way was better for them.

@truongsinh
Copy link
Contributor Author

@KazuCocoa at the moment both approaches are highly experimental thus I don't have a strong idea 😁. Though do you think the http server approach can do context-aware commands (some commands sent to native view, some to web view, some to Flutter view), and on iOS real devices (I understand that http server approach install another http server app on device under test, and it's always painful to install anything on iOS real devices).

On the other hand, Dart VM Service Protocol with extension ext.flutter.driver is undocumented protocol, thus direct communication to Dart VM might have broken changes in the future if the Flutter team refactor their code.

@KazuCocoa
Copy link
Member

Thanks :)
I was thinking to build it similar to https://github.com/appium/appium-espresso-driver , eventually.
The server communicates with appium-flutter-driver written in JS extends base driver. Clients communicate with the appium-flutter-driver. The appium-flutter-driver handles context, flutter or android/ios in the layer.
I haven't considered iOS real device much yet... As you also addressed highly experimental, mine is also very prototype :)

On the other hand,

yeah...

@KazuCocoa
Copy link
Member

KazuCocoa commented Jul 22, 2019

We can probably catch up with communication protocol with Dart VM between flutter_driver <=> dart vm by their tests => https://github.com/flutter/flutter/tree/180aa0c0b1fc645aa661a9aeedc21ed91c93ad00/packages/flutter_driver/test

here also (for example)
https://github.com/flutter/flutter/blob/4e4b9bd0b1ae094d4c837c8cd6d318d15be7fe40/packages/flutter_driver/lib/src/extension/extension.dart

We should call screenshot via ios/android drivers since flutter 's take screenshot is calling commands outside dart vm. e.g. https://github.com/flutter/flutter/search?p=4&q=screenshot&unscoped_q=screenshot

@truongsinh
Copy link
Contributor Author

Thanks, this really helps, so far I have been doing reverse engineering with FlutterDriver.connectedTo(printCommunication: true) 😂

truongsinh added a commit to truongsinh/appium that referenced this issue Jul 22, 2019
As discussed in appium#12919 (comment), we need to declare package name and class name for Flutter Driver. In the long run however, I believe this part of code should be refactored so that arbitrary driver can run without code change from `appium` core. Security risk should be minimal because that package must be installed beforehand anyway.
@truongsinh
Copy link
Contributor Author

@KazuCocoa @mykola-mokhnach could you take a look at #12945?

@KazuCocoa
Copy link
Member

Btw, is there any known limitation for https://github.com/truongsinh/appium-flutter-driver ?

e.g. it can run only debug mode, only on simulator etc...

@truongsinh
Copy link
Contributor Author

Btw, is there any known limitation for https://github.com/truongsinh/appium-flutter-driver ?

e.g. it can run only debug mode, only on simulator etc...

Currently the API is very limited, as documented in https://github.com/truongsinh/appium-flutter-driver#finders and at https://github.com/truongsinh/appium-flutter-driver#finders . I have been able to run the examples on Android emulator, Android real device (Pixel 2), iOS emulator.

I haven't run on iOS real device yet. As for mode, do you mean flutter mode or Android/iOS mode? Does it make sense to run test on non-debug mode :-? Anyway, as long as there's enableFlutterDriverExtension, we can control the Flutter app.

@jlipps
Copy link
Member

jlipps commented Jul 22, 2019

@truongsinh this is a great idea. If you get me your e-mail somehow I will invite you to the appium developer slack chat, for this kind of thing sometimes real time communication is easier. DM @jlipps on twitter might be a good channel.

@truongsinh
Copy link
Contributor Author

@truongsinh this is a great idea. If you get me your e-mail somehow I will invite you to the appium developer slack chat, for this kind of thing sometimes real time communication is easier. DM @jlipps on twitter might be a good channel.

DM'ed

@truongsinh
Copy link
Contributor Author

truongsinh commented Jul 23, 2019

We should call screenshot via ios/android drivers since flutter 's take screenshot is calling commands outside dart vm. e.g. https://github.com/flutter/flutter/search?p=4&q=screenshot&unscoped_q=screenshot

@KazuCocoa I published v0.0.5 with screenshot functionality. Actually we can have screenshot both from Dart VM and via jwproxy, depends on the needs. Screenshot from Dart VM is pure app, while screenshot via jwproxy may have extraneous element like top and bottom bar, as seen from these screenshots

flutter-screenshot
native-screenshot

@KazuCocoa
Copy link
Member

Thanks 👍 #12919 (comment)

Ah, okay.
Appium has commands like http://appium.io/docs/en/commands/mobile-command/
We can use either way as the command like mobile:viewportScreenshot.

--

btw, I was able to do on iOS real devices (I understand that http server approach install another http server app on device under test, and it's always painful to install anything on iOS real devices).

@umutuzgur
Copy link
Member

@truongsinh Should we close this issue since now we can communicate over slack?

@truongsinh
Copy link
Contributor Author

it's true we are communicating over slack, but if we keep this issue open until (1) Flutter is actually supported in Appium, or (2) we make a decision that Appium would not support Flutter, we can easily see the status.

I don't have a strong opinion, how about others?

imurchie pushed a commit that referenced this issue Nov 21, 2019
* Support Flutter driver

As discussed in #12919 (comment), we need to declare package name and class name for Flutter Driver. In the long run however, I believe this part of code should be refactored so that arbitrary driver can run without code change from `appium` core. Security risk should be minimal because that package must be installed beforehand anyway.

* `prepare` supersedes `prepublish`

This will also helps with install directly via git,
e.g. `npm i -g git://github.com/appium/appium`

* add flutter driver in deps
@ahashmi24
Copy link

@truongsinh
do we reach any conclusion? whether appium will support flutter based application? if yes please guide me with the initial setup for appium-flutter-driver or suggest to me if I can set-up appium-flutter-driver without bothering my existing Appium setup.

Many Thanks,
Ahmer

@stone20130104
Copy link

seems lots of us are waiting for appium-flutter-driver, could you please add flutter support in Appium as soon as possible, we are expecting to use it in Appium. Thanks!!!

@vijaydeepak-rezi
Copy link

vijaydeepak-rezi commented Dec 9, 2019

Thanks 👍 #12919 (comment)

Ah, okay.
Appium has commands like http://appium.io/docs/en/commands/mobile-command/
We can use either way as the command like mobile:viewportScreenshot.

--

btw, I was able to do on iOS real devices (I understand that http server approach install another http server app on device under test, and it's always painful to install anything on iOS real devices).

@KazuCocoa How can we Run on IOS Real device using Appium-Flutter-Driver . Do we need to make any specific changes in Desired capability ?

@mykola-mokhnach
Copy link
Collaborator

Closed as fixed

@gimnguyen
Copy link

I found out this field in flutter semanticLabel

When I add this attribute to element. I can interact with that element by: MobileBy.AccessibilityId("payment")
It looks like adding an ID to element, right?
However, Text is not fit. Because you can not get text value by this way.
See screenshot below.

2020-09-30_14h02_05

@supertgtline
Copy link

Hi, I have another question, I have multiple navigation bar tab can't add key, so how can I find correct tab I want to interact with them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants