I've loaded Android onto VirtualBox and would like to do the following:
1) Via the command line (Terminal Emulator), open up a downloaded app (call it Lyft)
2) Interact with the app as if I were a user working with the app normally on a phone --
2a) Pass my username/password to log in
OR
2b) Pass in new account credentials to create a new account
I imagine this thing is possible, given that Android is just a modified version of Linux but I'm not entirely sure where to get started. How could one do this sort of thing to emulate the experience of using the mobile app, without an API and without actually touching a phone?
You can use AndroidViewClient/culebra to create a script that does all you want. culebra --gui can also be used to create the script just pointing and clicking on the UI (check https://github.com/dtmilano/AndroidViewClient/wiki/Culebra-GUI).
You can launch the app , but accessing input fields is possible if the login form fields request focus immediately after launching . Otherwise , an interaction to click on the form field is a must
For launching the app , go to the android sdk directory or if its added to the path - connect the phone and run
adb shell
adb shell monkey -p com.android.chrome -c android.intent.category.LAUNCHER 1
where com.android.chrome should be replaced by the package name of the app you want to launch
Related
I have a problem that I think is related with Android permissions, however I need some of your expertise to confirm it.
I have testing the old Samgung J5(Not rooted) with Android 8.1.0, Appium 1.10.0 with UiAutomator2 and ADB 10.0.40 (In administration mode) on some Call Handling scenarios where I need to check if determined display elements (identity, call duration, hold activated, on transfer information, etc) are displayed to user. I have seen multiple solutions to do this task, inclusively using adb to do it, but lets focus only on this problem, using only the display elements (GUI).
Scenario, user receives call.
The com.android.incallui.service.SecCallPopupService comes into action:
User receives call
When I try to inspect the com.android.incallui.service.SecCallPopupService window the Appium cannot found it:
Appium Inpector
Neither on UiAutomatorViewer:
UitAutomatorViewer
On Comment link (xml dump) you can seen the display elements that Appium, and UiAutomatorViewer can "see". Same result was obtained by using the command adb shell uiautomator dump /data/local/tmp/uidump.xml
After that, I installed the Appium Studio and try out the Appium official "Inspector" and the result was:
Appium Studio Object Spy with full access to all display elements. Very intriguim... after some research I found the following package com.experitest.uiautomator.test (running in background) was immediatelly installed on the device when I clicked on Object Spy feature and I think that is responsible to retrieve all the interface elements.
On comment link (logcat) Some logcat logs after doind object spy on Appium Studio:
Analysing the logcat we can see that Appium studios was requesting
{"response":"true","params":[],"command":"richDump"} and the package uses
some kind of node:android.view.accessibility.AccessibilityNode. Maybe using something like the Acessibility Tree node to get the elements ? I don't know...
I have read some similar questions on Stackoverflow but some solutions involves to root the device or using de ADB (its not an option),
Tryng to su root the device and chmod 777 /data/local/tmp, but if it's really necessary, how then Appium Studio can read all display elements?
Do you know any other solution that allows me to get all interface elements without root the device? How can I call the "richDump"?
Thank You for you help.
So I have a python script to test an android app with the monkeyrunner tool and at a certain point in the script, I have command to launch the application on the mobile phone. The command is: device.shell('monkey -p com.blah.blah -v 500') and it works perfect. But my question is: "What is the meaning of the number 500?"
I found this command on a forum and some users are using the value 300 instead of 500 or other values.. For me it works with all of them but not without it. I just need to understand what the number does so I can fully understand what I do.
As per Android Documentation this command will launch your application and send 500/300/200(as specified by you) pseudo-random events to it such as clicks, touches, or gestures.
At work, we have an Android-based infotainment system that we're constantly deploying new versions to, on a half-dozen different test benches. The deployment script does the moral equivalent of:
for apk in ${apk_files}; do
adb install -r ${apk]
done
After this, we need to manually execute the following steps:
Set the home app to be one of our just-installed applications (Always, not Just Once)
Become a developer, and enable the Stay Awake option
Select the Google TTS engine for text-to-speech functionality rather than Pico
Executing these steps after each deploy is a giant PITA. People often forget one or more steps, and leave the test bench in a non-working state. This results in a bunch of 'bogus' bug reports that waste everbody's time.
Is there some way (using adb, perhaps) that we can automate these steps?
You can disable other home apps with adb shell pm disable .... I don't think there's a command line option to set apps as default. I remember looking into this before and there was a "preferred application" XML file where this was stored. If you want to look into it, the magic happens in PackageManagerService.addPreferredActivityInternal(). Looks like it writes the data to a file on disk: package-restrictions.xml. I suppose it's possible you could figure out the format thereof and write the file (you'd need root).
This is controlled by a system settings, "stay_on_while_plugged_in". You can set it using adb shell settings system put ....
The TTS engine is stored in a secure setting, "tts_default_synth". You can see the value like,
$ adb shell settings get secure tts_default_synth com.svox.pico
com.svox.pico
And you can set it with adb shell settings put secure "tts_default_synth" <the value>.
I noticed that if the value was not been previously set, when you get the value using the settings command you get null and it's not listed in settings list, even though there is a default value. As of Android 6 (I think), settings are no longer in a DB but rather are stored in XML files in /data/system/users/0/settings_*.xml. You can see the values therein.
I need to launch an app which is in different work profile (Android For Work). If install the app in personal profile then I am able to launch the app from the personal profile on the same device.
However, When I install the app only in the work profile then I am not able to launch the app through adb command.
As per my understanding, google keeps two different containers for personal and work profile. I think the work profile has different space and adb does not have any access to that app and workspace of work profile.
I need to launch the app through appium
If anyone has the answer to the above problem, please answer. Thanks in Advance !
Do you mean launching application on different user account ? check this link please : https://stackoverflow.com/a/24093533/5093606
You can get try to get list of accounts using
adb shell pm list users
and if you working account is there, try
adb shell am start --user WORKING_ACCOUNT com.example.MainActivity
Yes, there is way to launch the apps by using Appium/Adb commands. Instead of appium use adb commands to launch the apps.
The app which you have used for AndroidForWork enrollment, it should be in android:debuggable mode. Set debuggable mode to true and build the apk.
Once the device is enrolled/Configured Androidfor work then get the list of users.
adb shell pm list users UserInfo{0:Drew:13} running UserInfo{10:Work profile:30} running
Get the workprofile user id. In this case 10 is the id. Use the user id to launch the apps.
adb shell am start --user 10 -n "com.android.vending/com.google.android.finsky.activities.MainActivity"
Note: If the provision app is not enabled in Debug mode then you don't have the access to the work profile user.
Turns out I was able to accomplish this with Appium Desktop by adding another parameter to the inspector:
optionalIntentArguments text --user 12
Where '12' is the work profile id you'd see from typing this:
adb -d shell pm list users
Users:
UserInfo{0:Ken Corey:13} running
UserInfo{12:Workspace:50100030} running
I have created a batch file that fires adb shell command to start activity, send events to enter text into username and password text fields & click login buttons to navigate to other activity(screen).
how can i know that application navigate to other activity or want to know the response that tell me if login successful or not using shell commands.
Thanks,
Bhushan
Dollop, where I work, provides a record-and-play-back tool for Android that will do the things you suggest and save you the hassle of interacting with low-level shell commands. (It is currently limited to running on Windows in communication with Android devices). It's easy to configure and use, requires no programming, runs against real devices (which do NOT have to be rooted) and automatically saves screenshots as it plays tests. I'd love to hear your feedback.
try to get process (ps aux | grep xxxxx ) information to know the activity running or not