wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.15k stars 1.92k forks source link

Android Feature Request; Device API can run adb commands #3912

Open alkimake opened 1 year ago

alkimake commented 1 year ago

Some of the tests might need to run adb commands on the fly for the emulator that is already running. For example enabling and disabling WiFi, data...

It would be nice that device client API exports/exposes adbCmd that has already implemented in android drivers.

something like

device.adb("shell svc wifi diable")
d4vidi commented 1 year ago

Thanks @alkimake. We've contemplated introducing that into our official API's in the past (long ago), I'm having trouble recalling why we eventually decided not to do so. In any case, I'm putting this down as a contribute-able issue. I think a more suitable API for this would be:

device.adb.shell('svc wifi disable');

I'm somewhat reluctant to allow for non-shell commands because the support for them are not uniform across the various devices (i.e. google emulators, vs. Genymotion local vs. Genymotion-cloud vs. real devices)

github-actions[bot] commented 1 year ago

Hello! We appreciate you bringing this issue to our attention. It looks like this could be a valuable addition or fix to our project. We believe that this feature would benefit greatly from contributions from the community, even from first-time contributors.

If you're interested in contributing to this feature, please take a look at our contribution guide. It has all the information you need to know about how to submit a pull request and contribute to our project.

You're also welcome to join our Discord server and discuss this feature with the collaborators or other contributors under the channel 'contributions'.

Please feel free to reach out to us if you have any questions, or need help with anything. We appreciate your feedback and look forward to working with you!

alkimake commented 1 year ago

Hi @d4vidi,

Thanks for quick reply. If i find a time i will try to make a PR with your suggested API.

d4vidi commented 1 year ago

Hi @d4vidi,

Thanks for quick reply. If i find a time i will try to make a PR with your suggested API.

Would be exciting to have!

drmas commented 10 months ago

You can do similar behaviour using

const cp = require('child_process');
cp.execSync('adb shell svc wifi diable')

Do we need an api for just that?

noomorph commented 10 months ago

I'd correct @drmas: adb -s ${device.id} shell svc wifi disable