I am building an Android application that is designed to help with load testing. When the app launches we are sending extra values to the main activity so that we can control what kind of load each app executes. Currently, we are doing this, scripted, via the terminal using adb directly which is pretty straight forward:
adb shell am start -e key1 value1 -e key2 value2 -n bla.bla/bla.MainActivity
For debugging purposes, I'd like to be able to do this from IntelliJ but I don't see anything in my run configuration screen that let's me pass anything to adb. Is this possible?
Might be waaaaaay late on this one, but you can always try the BashSupport plugin on the IntelliJ Repo.
Related
I am trying to make integration tests which test Fingerprint.
According to google doc to invoke finger touch on emulator from terminal you need to use:
adb -e emu finger touch < finger_id >
And this works for me. In my case id is 45146572. However in test you cannot input this command on your own as it should be done automatically.
I've been trying various things to make a workaround (eg. trying to understand how app is receiving information from sensor - maybe by some kind of broadcast intent etc.) and for now I still don't know how to do it.
I know that UiAutomation and UiAutomator's class - UiDevice has method
executeShellCommand
and I think that this might be helpful. But even if I do something like:
getUiDevice().executeShellCommand("-e emu finger touch 45146572");
My device won't react to it (I've tried on both classes and various threads). I believe this is caused by the fact executeShellCommand is running already inside shell. So it's like I've typed to terminal
Kamils-MacBook-Pro:~ F1sherKK$ adb shell
root#generic_x86_64:/ #
And I guess that's the problem, because google wants:
adb -e emu finger touch
not
adb shell -e emu finger touch
My knowledge about shell might be not enough maybe. I've looked through all documentation many times.
Do you have any idea how to call finger touch from shell?
I believe you have to be using different format of password. It should be "aa11aa" which is LetterLetterNumberNumberLetterLetter.
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
I need to forward a port on an android emulator, right now I had to type the command every time:
adb forward tcp:23946 tcp:23946
Is there any way to make this automatic? I tried to replace adb with a script but that command won't work until the device is up and running.
Any ideas?
Based on this answer (which I've tested and works, though it wasn't for a scenario like this one), you could simply write a script that waits until the emulator is booted.
Something like (pseudocode, don't know which platform you're on) :)
emulator #emulator-name
while ('adb shell getprop init.svc.bootanim' == "running") sleep(10s)
adb forward tcp:23946 tcp:23946
I already posted similar question, but still could not get my job done, so this a a second attempt, where
I would like to more clearly state my stumbling block.
So basically I am in Android phone's adb shell, communicating with the GPRS modem by sending AT commands.
I am able to do it by redirecting at command to the device file representing the modem; and I can read back
the response using cat utility running on the background (started earlier). I implemented it in a script
which can send a single AT command and read back the response. For example, here is the script to
send at+cops? to get the name of the operator the mobile is camping on:
#SendATCommand script
cat /dev/pts/7 &
echo -e at+cops?\\r > /dev/pts/7
The output looks as follows:
# ./sendATCommand
./sendATCommand
#
+COPS: 0,0,"AT&T",6
OK
/dev/pts/7: invalid length
Now here are two problems which I cannot resolve:
I still need to manually press ENTER button to get back adb shell prompt "#". Is there a way to return
to "#" prompt programmatically? Again, I am in adb shell.
The displayed response cannot be captured, neither in a variable, nor in file, (such as(#./sendATCommand > output.txt) Output.txt file will be empty. I tried various redirections, but still did not get it to work.
Can anyone please help me resolve those two problems (if ever possible)? Ultimately I want this little script to be
called from a "super" script (e.g. Perl or Powershell) running on PC to which my Android device is
connected, but there is no way to do it until those two problems resolved. Thanks a lot in advance!
I suggest that you try out my atinout program which should be exactly what you are asking for: a program to send AT commands from the command line and capture the output.
In your case the result should be like
$ echo 'at+cops?' | atinout - /dev/pts/7 -
+COPS: 0,0,"AT&T",6
OK
$
and to capture the output just put a file name instead of the last -.
I had similar problems with redirecting output to file. I resolved my problem by adding CMD /c in front of the echo command. I.e. if I understand correctly you need to tell the system that it needs to wait until command finishes executing and only then redirect output to a file. I was doing it in DOS.
Since you are running on ANDROID try adding sh -c in front of your command. Hope it helps.
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