Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we use UIAutomator in android applications?

I want to know can we use UIAutomator in our applications ? I want write an app that open another application, write some Text in that application EditText and then press some buttons (like open Hangout and write a text on it and send the message). Can you suggest me how can I do this?

I have searched the net and I could only find out I can test my UI with UIAutomator, but I don't know if I can use it to write an Android application (not jar file) and run it on my Android device to do this.

like image 483
Farhad Navayazdan Avatar asked Apr 01 '15 21:04

Farhad Navayazdan


People also ask

Where can I find Uiautomator in Android Studio?

To launch the uiautomatorviewer tool: Launch the target app on a physical device. Connect the device to your development machine. Open a terminal window and navigate to the <android-sdk>/tools/ directory.

Is Uiautomator deprecated?

This class is deprecated. It is no longer necessary to extend UiAutomatorTestCase.

Can we automate Android app?

UI Automator Based on the features mentioned before, Appium is the most popular and preferred choice for Mobile Automation for Android devices. The most important reason for Appium as a preferred choice is because the same programming language can be used to automate both iOS and Android operating systems.


1 Answers

This isn't possible.

UiAutomator 2.0 relies on Instrumentation which is only available when you run your test using am instrument .... Regular (non-test) apps don't have access to Instrumentation.

Shell-based UiAutomator is similar. You execute tests using adb shell uiautomator runtest ... and UiAutomatorTestRunner takes advantage of the fact that it is running as the shell user to do things that normal apps don't have permission to do.

If you use Runtime#exec(..) to call either am instrument or uiautomator runtest, the command won't run as the shell user (it will use your application's uid), and will fail because it doesn't have the necessary permissions.

like image 169
Allen Hair Avatar answered Sep 18 '22 03:09

Allen Hair