Closed Bug 1637251 Opened 4 years ago Closed 4 years ago

geckodriver can't find capabilities for platformName "android" when running Android 6 and earlier

Categories

(Testing :: geckodriver, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: t.feliu, Unassigned)

Details

Attachments

(6 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36

Steps to reproduce:

I'm using the Support for Firefox on Android described in https://github.com/mozilla/geckodriver/releases/tag/v0.26.0 in order to connect to Firefox installed in an android emulated device.

As instructed there, I'm using the following capabilities to start selenium-webdriver on nodejs:

"platformName": "android",
"moz:firefoxOptions": {"androidPackage": "org.mozilla.firefox"}

Relevant npm packages used:

    "geckodriver": "1.19.1",
    "selenium-webdriver": "^4.0.0-alpha",

Actual results:

The webdriver builder produces SessionNotCreatedError: Unable to find a matching set of capabilities.

If "platformName" is set instead to "linux", then Firefox starts in the emulated device, but the builder produces Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1

Expected results:

The webdriver builder should not fail when using "android" platformName capability

You shouldn't set the platformName to Android. Our behavior is similar to the one from chromedriver.

Please attach a trace log so that we can help. Also the adb logcat would be helpful.

Flags: needinfo?(t.feliu)
Attached file adb logcat
Flags: needinfo?(t.feliu)

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] from comment #1)

You shouldn't set the platformName to Android. Our behavior is similar to the one from chromedriver.

Would that mean that the info on https://github.com/mozilla/geckodriver/releases/tag/v0.26.0 regarding platformName is wrong?

Please attach a trace log so that we can help. Also the adb logcat would be helpful.

Files attached, thanks :)

Ok, so the problem here seems to be executing the package command that doesn't seem to exist anymore in newer Android releases (at least since Android 7). And I assume you have one of those in your emulator.

package resolve-activity --brief org.mozilla.firefox | tail -n 1

At least for Android 10 it needs to be:

pm resolve-activity --brief org.mozilla.firefox | tail -n 1

Can you please tell me what that returns in your case? Also please add the returned activity name to the androidActivity capability, so that geckodriver doesn't have to query itself for the default activity. That's at least a workaround for now.

Please let me know if that works for you. Thanks!

Flags: needinfo?(t.feliu)
Blocks: 1584911
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

pm resolve-activity --brief org.mozilla.firefox | tail -n 1

Can you please tell me what that returns in your case?

Looks like pm resolve-activity does not exist:

Error: unknown command 'resolve-activity'
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_ID] [FILTER]
...

Also please add the returned activity name to the androidActivity capability, so that geckodriver doesn't have to query itself for the default activity. That's at least a workaround for now.

To find out the activity I started the installed Firefox app with adb shell monkey -p org.mozilla.firefox 1. That shows those lines in the logcat:

05-22 13:27:27.936   960  1767 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.mozilla.firefox/.App} from uid 0 on display 0
05-22 13:27:28.284   960  1779 I ActivityManager: Start proc 2195:org.mozilla.firefox/u0a55 for activity org.mozilla.firefox/.App
05-22 13:27:28.488  2186  2186 I art     : System.exit called, status: 0
05-22 13:27:28.489  2186  2186 I AndroidRuntime: VM exiting with result code 0.
05-22 13:27:29.044  2195  2195 I GeckoApplication: zerdatime 441851 - Fennec application start
05-22 13:27:29.124   960  1611 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x200000 cmp=org.mozilla.firefox/org.mozilla.gecko.BrowserApp} from uid 10055 on display 0
05-22 13:27:29.399   960   982 W art     : Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.activityPaused(android.os.IBinder) from ActivityManagerService.java:6439 waiters=1 for 140ms
05-22 13:27:29.415   960   989 D         : HostConnection::get() New Host Connection established 0xa0ba45e0, tid 989

Therefore I added the androidActivity capability org.mozilla.gecko.BrowserApp. That produced the following geckodriver trace log:

1590154742487	geckodriver	DEBUG	Listening on 127.0.0.1:4444
1590154744523	webdriver::server	DEBUG	-> POST /session {"desiredCapabilities":{"browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","androidActivity":"org.mozilla.gecko.BrowserApp"},"platformName":"linux"},"capabilities":{"alwaysMatch":{"browserName":"firefox","moz:firefoxOptions":{"androidPackage":"org.mozilla.firefox","androidActivity":"org.mozilla.gecko.BrowserApp"},"platformName":"linux"}}}
1590154744535	mozdevice	WARN	adb server response contained hexstring length 106 and message length was 106 and message was "emulator-5554          device product:sdk_phone_armv7 model:sdk_phone_armv7 device:generic transport_id:1\n"
1590154744535	geckodriver::android	DEBUG	Android port forward (39909 -> 2829) started
1590154744541	mozdevice	DEBUG	execute_host_command: >> "host:transport:emulator-5554"
1590154744541	mozdevice	DEBUG	execute_host_command: << []
1590154744541	mozdevice	DEBUG	execute_host_command: >> "shell:pm clear org.mozilla.firefox"

thread 'webdriver dispatcher' has overflowed its stack
fatal runtime error: stack overflow

I also tried with org.mozilla.firefox.App value for androidActivity capability, which produced the same error.
I'm attaching a new abp logcat file, in case that helps.

Cheers,
Toni

Flags: needinfo?(t.feliu)
Attached file New adb logcat file

I assume it's Firefox 68, which you are using here? Then org.mozilla.firefox/org.mozilla.gecko.BrowserApp for the browser activity should be fine. Also which version of Android are you using? I haven't seen mentioning this detail yet.

Flags: needinfo?(t.feliu)

I'm not using Firefox 68 but Firefox 51. The android version requested in sdkmanager is is android-23

Flags: needinfo?(t.feliu)

Please note that Firefox 51 on Android is way behind our supported release matrix. If you want to test with Fennec (Firefox on mobile) please upgrade to the latest 68ESR release, and try again.

Flags: needinfo?(t.feliu)

Installing fennec-68.8.1.multi.android-arm.apk produced the same result as before on geckodriver trace log, for both "androidActivity":"org.mozilla.gecko.BrowserApp" and "androidActivity":"org.mozilla.firefox.App"

Flags: needinfo?(t.feliu)

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(hskupin)

Ok, so org.mozilla.gecko.BrowserApp should be the right one here.

Nothing in the recently attached adb logcat shows that Marionette is enabled. So is the log level for geckodriver set to trace? As best also always attach the associated geckodriver.log file.

Severity: -- → S3
Flags: needinfo?(hskupin) → needinfo?(t.feliu)

I believe the issue has to do with geckodriver not being able to communicate with the emulator.

In tracelog, after execute_host_command: >> "shell:pm clear org.mozilla.firefox" the expected Success reply from the emulator is not there.
If I manually call adb shell 'pm clear org.mozilla.firefox', the output is indeed Success.

Flags: needinfo?(t.feliu)
Attached file geckodriver_trace.log
Attached file adb_logcat.log
No longer blocks: 1584911

(In reply to Toni from comment #9)

I'm not using Firefox 68 but Firefox 51. The android version requested in sdkmanager is is android-23

This seems to be Android 6.0 (Marshmallow). In our CI the lowest Android version we support is 7.0 right now.

So do you clearly have to use Android 6.0 in the emulator, or would you be able to at least upgrade to Android 7?

I would like to avoid having to add support for that old Android version. Thanks.

Flags: needinfo?(t.feliu)

Switching from android-23 to android-25 solved the issue. Thanks!

Great to hear that Toni. As such I will mark this bug as wontfix, given that we don't have the resources to support Android releases earlier than 7.

Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(t.feliu)
Resolution: --- → WONTFIX
Summary: geckodriver can't find capabilities for platformName "android" → geckodriver can't find capabilities for platformName "android" when running Android 6 and earlier
No longer blocks: 1649094
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: