J
J
jslby2020-06-22 18:45:56
Android
jslby, 2020-06-22 18:45:56

How easy is it to automate an Android app?

I'm trying to automate the application using https://github.com/appium/appium-uiautomator2-driver
I need to:
1. Run a third-party application (installed earlier from the apk)
2. Click on the xpath from the dump (there is a dump, I'll just dump the xpath)
3. Find an input field in the application (scroll is possible)
4. Enter text there

I found a file with commands in the sources, but I can’t connect the device, I only have its unique code from adb devices. Can you please poke your nose on how to run a simple test?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
h4r7w3l1, 2020-07-20
@h4r7w3l1

Isn't it easier for adb to do all of the above actions?
we raise adb, we get a serial (if the execution is on 2+ devices / emulators). port 5555 is the first one, which seems to be default, but I could be wrong.
upload apk, if not installed, install (with one adb command)
then for good, you need to study the available activity applications, look at the documentation, the command called in my opinion a package manager that displayed a list of applications and their activation (everything comes with stock adb except for apk trusted of course)
Based on the selected activity (as a rule, main activity for many apk)
If, when opening, the cursor focus is placed on the form, we pass the input text to adb, go to the next form by sending the send key (in the documentation, see what number the TAB key or "joystick down" goes under) in this spirit all forms, and submit will be executed by passing the send key value number "enter"
we get the state of the screen with an xml dump, we parse it with the built-in Linux tools either on the device itself or we pass the context by the file / output of the cat stream. We determine success / failure, do all the necessary things on the host side, and turn on a new one.
ps this is the most trivial option that does not require anything other than stock adb and a device.
As part of frameworks, look at androyd studio, it also knows how to write and assemble unit tests more than enough. They are usually saved on the device as a file, and are launched by adb by initializing the launch of the test from a file. In principle, this approach will give more flexibility to navigate and interact with elements of both native and other applications. I mastered in 45 minutes the main points of which were enough to automate the much more difficult logic of autotests.
z.s.s. I am writing everything as a keepsake, it was a long time ago, I can partially confuse some names or commands, but I think the essence is clear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question