How to use Android UI Automator without access to source code - android

so I am trying to learn test automation on an Android, Basically I want to learn how to use Google's UI Automator, however, it seems like all tutorial that I could find requires me to have access to the source code of the app under test.
I found this repo AndroidTestWithoutSource it uses espresso but requires me to re-sign the APK.
My target environment basically is a production test environment I mean like install the app under test on an android device then connect the device to my PC through ADB, for learning purposes I like to test youtube or even the native settings app.
Is my goal even possible with UI Automator? like being able to test apps installed in the device like appium does?
I would really appreciate a sample to that launch youtube app just to get me started.
Thank you!

Yes you can for instance use UI Automator viewer to get the resource ids (textview ids, edittext ids, etc) you want to click or act on.
After that you can write a UI Automator test that starts the app you're going to test (having the package name) and acts on the resource ids you previously collected.
Hope this helps.

Related

How to create stand alone UI Automator test using UI Automator testing framework

I use Appium to create instrumented tests. I would like to switch over to a native testing client for Android, and there appear to be a couple options
1) Espresso testing framework (for single app)
2) UI Automator testing framework (for multiple apps)
and as per the suggestion, I imagine I should use UI Automator testing framework since I will be testing multiple instances of the same app on multiple devices.
However, all tutorials and information on how to use UI Automator testing framework indicate its usage from within an Android application project.
So my question is, can I create a stand alone project, say like a Gradle IntelliJ project that is not coded from within an Android Studio project?
Is this technically possible?
edit
Even the sample app includes the test within an android app module project. If I can define any apk build I want, I guess I have no problem using an application project. Maybe that's the direction I need to go in?
edit
Just looking at the sample test, it looks like the framework is deeply coupled within the android project, and I'm disappointed I can't make a stand alone framework.
What I learned is I can create a separate app module with no app source, and only test code, then use a script to automate the install of the build from another app module.
However, the test code is run internally to the device as an APK, and thus testing is restricted to one device only AFAIK for now.

Device farm interactive testing done programmatically

AWS has a 'remote-desktopy' feature (https://aws.amazon.com/blogs/aws/aws-device-farm-update-remote-access-to-devices-for-interactive-testing/) as part of its device farm, but it is far too slow to use in browser. Does anyone know if there is a programmatic/CLI way to interact with that system?
I would like to test the functionality of a third party app on a cloud based mobile testing platform such as Firebase Test Lab, or AWS device farm. I have no way to instrument this app.
The testing requires I download two apps on the device (one is the app to be tested, the second has a supporting function). At the start of the test I have to launch the support app, and then switch over to the app I am testing. I imagine the only way to do this is via the device's 'home' button. The actual testing is just a set of basic UI interactions.
Does the Firebase Test lab or other platform have a feature that I could use to do this?
If there was a way to extract events from the AWS remote-desktop, I could see an approach using a selenium/other webdriver. But I am not sure this a real option.
Any thoughts on this are appreciated.
Thanks!
"The UI Automator APIs allow you to write robust tests without needing to know about the implementation details of the app that you are targeting. You can use these APIs to capture and manipulate UI components across multiple apps" (documentation)
To tap the Home button you can use UiDevice.pressHome().

Regarding instrumentation test cases for APK

I have developed an Android application that parses RSS feed from a website.
I have developed instrumentation test cases for application since I have access to code. So far everything is ok.
Now I want to ask is there any way or is it possible through which I can develop instrument test cases for apk when I don't have access to code.
If yes then what are all components in Android that can be tested through.
Thanks in advance
Now I want to ask is there any way or is it possible through which I
can develop instrument test cases for apk when I don't have access to
code.
You can test it using Appium
If yes then what all components in Android can be tested through.
I have tested UI and flow for app.

Android black-box testing (no access to app code). Is Google's Espresso a good choice?

I have recently been looking in to Espresso, which looks for me very promising.
I am recently working in an Android test project, and we are recently using Espresso as we see some benefits with that. Unfortunately the setup in the company I work for is such that I do not have access to the entire code for the Application we are testing.
So how I can create a test using android studio?
You can use UIAutomator to get the ids of various views.
See here
With view ids you can perform assertions/click and other actions on them
An example
onView(withId(R.id.play_search_container)).perform(click());
Hence you can go through the whole UI flow by clicking on various elements.
if you want to write a test outside of application's code, I mean: pure black-boxing, Espresso would be a pretty hard to implement as it needs a bit of application architecture (the same thing is with Robotium or `UiAutomator): names of Activities, views texts, contentDescriptions or idies.
You can use instead of Espresso:
UI/Application Exerciser Monkey
The Monkey is a program that runs on your emulator or device and
generates pseudo-random streams of user events such as clicks,
touches, or gestures, as well as a number of system-level events. You
can use the Monkey to stress-test applications that you are
developing, in a random yet repeatable manner.
monkeyrunner(requires Python language programming basics)
The monkeyrunner tool provides an API for writing programs that
control an Android device or emulator from outside of Android code.
With monkeyrunner, you can write a Python program that installs an
Android application or test package, runs it, sends keystrokes to it,
takes screenshots of its user interface, and stores screenshots on the
workstation.
The monkeyrunner tool is primarily designed to test
applications and devices at the functional/framework level and for
running unit test suites, but you are free to use it for other
purposes.
Calabash
Calabash is a framework that enables Automated UI Acceptance Tests
written in Cucumber to be run on iOS and Android applications.
Calabash works by enabling automatic UI interactions within an
application such as pressing buttons, entering text, validating
responses, etc.
From: Introduction to
Calabash
Hope it will help

how to do cross app automation testing for android

lots of apps now need to interact with other apps. i'll give some examples:
take picture by calling system camera
open url like http://www.shihuangzhilu.com in a browser
android instruments can only test one app per time. can we do automation testing here?
You can't explicit definitely not using the current testing framework of android.
What you can do is use robotium, and then check if you have gotten the values back, and that you are no longer within your application/activity, that's the only way i can think of.
Yes, you can test across applications, see monkeyrunner:
http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html
(not to be confused with Monkey, another android tool)

Categories

Resources