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
469 stars 184 forks source link

ERROR: Cannot read property 'match' of undefined #410

Closed FotogyDS closed 1 year ago

FotogyDS commented 1 year ago

Hey there!

I focused on working on a testautomation for a little flutter app i made all in the favor for my university papers.

The Problem:

When i start an appium server, an android emulator, and my script in python, i get this error message: "UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot read property 'match' of undefined". Following an closed issue on this topic didn't help me, just to clear that.

This is the whole error message from the VS Code Terminal:

Traceback (most recent call last): File "c:\Users\XRAYAdmin\Documents\TestAutomation.py", line 9, in driver = webdriver.Remote('http://localhost:4723/wd/hub', dict( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\XRAYAdmin\AppData\Local\Programs\Python\Python311\Lib\site-packages\appium\webdriver\webdriver.py", line 230, in init super().init( File "C:\Users\XRAYAdmin\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 286, in init self.start_session(capabilities, browser_profile) File "C:\Users\XRAYAdmin\AppData\Local\Programs\Python\Python311\Lib\site-packages\appium\webdriver\webdriver.py", line 320, in start_session response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\XRAYAdmin\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute self.error_handler.check_response(response) File "C:\Users\XRAYAdmin\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot read property 'match' of undefined Stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot read property 'match' of undefined at getResponseForW3CError (C:\Users\XRAYAdmin\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9) at asyncHandler (C:\Users\XRAYAdmin\AppData\Local\Programs\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:380:37)

I really hope one of you can help me out, this is really important for me.

Edit:

Forgot to add the Appium Server Logs, for everyone interested, here they are: appium-server-logs.txt

KazuCocoa commented 1 year ago

Please try out the latest version with Appium 2.0

FotogyDS commented 1 year ago

I've tried running it with Appium 2.0, it still gives me the same error message. We are pleased to send any information If you need any.

Idea: I found an similar issue where the Observatory URL is not given in the LOGCAT. Maybe it has something to do with that.

AlcoMaidoNyan commented 1 year ago

Same issue, appium 2.0.0-beta.53

KazuCocoa commented 1 year ago

Was the app process running in the session start?

I found an similar issue where the Observatory URL is not given in the LOGCAT. Maybe it has something to do with that.

I saw this case when the app process was running before. Flutter app does not print the observatory URL without the process starting.

Please check if the logcat has observatory URL log matches https://github.com/appium-userland/appium-flutter-driver/blob/main/driver/lib/sessions/observatory.ts#L182-L189

FotogyDS commented 1 year ago

The Observatory URL is not being printed out in the LOGCAT Window. But i get the following piece printed out:

The Dart VM service is listening on http://127.0.0.1:34876/i3qm20sNPp0=/

Not quite the same, i also switched over to a real device because the Android emulator pilled the CATLOG with errors, which annoyed me. Those errors dont appear on the CATLOG of the real device.

KazuCocoa commented 1 year ago

hm, could you double check the app process is not running before starting a session? Afaik, if the process is already running, the app won't print the url

FotogyDS commented 1 year ago

I am afraid that the process is completely shut down at the time i start the test. Furthermore did i restart the whole PC to ensure that no process is running on the current machine, aswell as the emulator. May i ask what process specifically shouldn't be running ?

KazuCocoa commented 1 year ago

it is the application under test

FotogyDS commented 1 year ago

Ah alright, no that application is not running. I make sure to restart the system. please tell me if you need any further information.

FotogyDS commented 1 year ago

In addition to my latest comment: I also uninstall the application before any test i run, just to make sure that I install the latest version of the Flutter App. Please let me know if you need any Information like Logs, Code and Screenshots.

KazuCocoa commented 1 year ago

I saw a case that got logcat output restrictions by probably manufacture customization. Then, you can relax it via developer options -> logger buffer sizes to 256k for example

FotogyDS commented 1 year ago

The logger buffer size was already at 256k. Increased it to 1Mio. Still doesn't work.

FotogyDS commented 1 year ago

I don't want to come over annoying or anything but could you please make a "Setup and installation"-Guide regarding the newest versions. Maybe something changed in the way i setup my workstation than the current versions need to be. Please Please Please

KazuCocoa commented 1 year ago

Probably you could try out https://github.com/appium-userland/appium-flutter-driver/tree/main/example/sample2 to check if the issue is in the device. Myself hasn't tried recent versions' Flutter so I only could say https://github.com/appium-userland/appium-flutter-driver#usage.

FotogyDS commented 1 year ago

Well, i tried setting up the enviroment on a different pc in a different network and it still didn't work. But I might have found a potential cause. Whenever i was setting up the JAVA_HOME Path I usually used the Java JDK from Liberica. Using that Java JDK doesn't give me the annoying error message: "Cannot find java.exe in JAVA_HOME or in PATH", which i would get if i would be using the Oracle java JDK. Maybe that is one cause of connecting error? Or it could be that my java version is too new for the other programs. Could you please provide Information on Versions of every component (Appium, appium-flutter-driver, flutter SDK, Dart, Java, android emulator OS...etc) that are confirmed working flawlessly together? Thanks in advance!

FotogyDS commented 1 year ago

I would also like to address that the flutter example given at "flutter_app_under_test" is outdated and no longer compatible with the newest version of Flutter, since widgets like buttons been renewed but this example still uses the older version and the syntax doesn't seem to line up with the newest version of flutter. Just to let you know, maybe you wanna update the example.

bikashmoneynmore commented 1 year ago

@KazuCocoa I have to upload my automation framework on AWS device farm, it support upto appium 1.22.2, and when i am trying to run my script with appium 1.22.2 then getting same error "ERROR: Cannot read property 'match' of undefined". And when i upgraded my appium version to appium 2 then is running perfectly. But the main issue is AWS device farm support appium upto 1.22.2 only so i have to make the script run in appium 1.22.2 only

KazuCocoa commented 1 year ago

Then, the only possible way is to use Flutter v2. v3 needs a newer version with Appium 2.0.

bikashmoneynmore commented 1 year ago

But our devloper use flutter v3 for devlopment. Does our appum 1 doesn't support flutter v3..?

On Sat, 4 Mar, 2023, 15:27 Kazuaki Matsuo, @.***> wrote:

Then, the only possible way is to use Flutter v2. v3 needs a newer version with Appium 2.0.

— Reply to this email directly, view it on GitHub https://github.com/appium-userland/appium-flutter-driver/issues/410#issuecomment-1454684038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZK7RXSWXFKV7UZB7HBCSCLW2MG2BANCNFSM6AAAAAAUU7ST2I . You are receiving this because you commented.Message ID: @.***>

KazuCocoa commented 1 year ago

No, unfortunately since v3 changed the observatory url message format. The change is only available in newer ones, which are available via Appium 2 nowadays.

bikashmoneynmore commented 1 year ago

Ok, thanks for the reply.

On Sat, 4 Mar 2023 at 15:35, Kazuaki Matsuo @.***> wrote:

No, unfortunately since v3 changed the observatory url message format. The change is only available in newer ones, which are available via Appium 2 nowadays.

— Reply to this email directly, view it on GitHub https://github.com/appium-userland/appium-flutter-driver/issues/410#issuecomment-1454686103, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZK7RXVEH74PFSDWWGKSMW3W2MHVHANCNFSM6AAAAAAUU7ST2I . You are receiving this because you commented.Message ID: @.***>

--

Bikash Kumar Roshan

QA Engineer | moneyNmore

bikashmoneynmore commented 1 year ago

@KazuCocoa Please reply for this issue, Our QA team got stuck in this place https://github.com/appium-userland/appium-flutter-driver/issues/422

FotogyDS commented 1 year ago

@KazuCocoa Please reply for this issue, Our QA team got stuck in this place #422

Did you get it to work somehow? Which Versions are you using to make it working? Flutter 2 with appium 1.22.3 and the current Appium flutter driver ?

quixony commented 1 year ago

Is there a quick workaround to adjust appium to overcome the not found string? Can anyone please point out where adaption is necessary? I am stuck there currently but I am not able to downgrade flutter (not my decision) :-(

FotogyDS commented 1 year ago

Is there a quick workaround to adjust appium to overcome the not found string? Can anyone please point out where adaption is necessary? I am stuck there currently but I am not able to downgrade flutter (not my decision) :-(

A colleague of mine suggested to change the appium source code to search for the right string. Reference to the string search code would be this: https://github.com/appium-userland/appium-flutter-driver/blob/main/driver/lib/sessions/observatory.ts#L182-L189

But it confuses me, since it is basically searching for both versions of the string: (Observatory listening on |An Observatory debugger and profiler on\\s.+\\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+), );

FotogyDS commented 1 year ago

@KazuCocoa Now i have another problem, trying to use the newest Versions leaves me with not being able to download the Flutter driver within Appium. Using Appium driver list only showes me those drivers: image Eitherway i tried launching the Python test file and it gave me following error: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'Flutter' and platformName 'Android'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: Could not find installed driver to support given caps)

FotogyDS commented 1 year ago

Update: I got everything to work,I assumably used the wrong versions. Thank you very much everyone and have a good one. Solution: Use the latest versions of Flutter and appium, Start the appium server in the Nodejs command prompt and don't forget to install the flutter driver by using appium driver install --source=npm appium-flutter-driver, don't forget to use enableFlutterDriverExtension(); aswell as putting import 'package:flutter_driver/driver_extension.dart'; in your Flutter code. This approach solved the Match undefined Problem

quixony commented 1 year ago

Just for information: I could solve my problem as well: it was remains from the previously installed appium-version which was not cleaned up properly on update and/or uninstall. Setting up the environment on a clean system (without having the release version installed first), it works out flawlessly (with flutter 3).

FotogyDS commented 1 year ago

Just for information: I could solve my problem as well: it was remains from the previously installed appium-version which was not cleaned up properly on update and/or uninstall. Setting up the environment on a clean system (without having the release version installed first), it works out flawlessly (with flutter 3).

That's correct, Upgrading from Appium 1 to Appium 2 left me with the same Error Code. One thing i must admit that i didn't try is upgrading from Appium 1 to Appium 2, install the Appium flutter driver via the command prompt and also start the server within the command prompt. I kept on using the "Appium Server GUI" which might have been the problem since it was running on a entirely different Appium Version.

rabiulsarker commented 1 year ago

Update: I got everything to work,I assumably used the wrong versions. Thank you very much everyone and have a good one. Solution: Use the latest versions of Flutter and appium, Start the appium server in the Nodejs command prompt and don't forget to install the flutter driver by using appium driver install --source=npm appium-flutter-driver, don't forget to use enableFlutterDriverExtension(); aswell as putting import 'package:flutter_driver/driver_extension.dart'; in your Flutter code. This approach solved the Match undefined Problem

after doing all of this, issue remained. observatory URL is unique and for every run, it is generating new URL. And this URL can't connect