VISHAL VIRADIA
VISHAL VIRADIA

Reputation: 1418

how to start "uiautomator test run" from android code?

Reference Links: Link1, Robotium Link2

as we know that from Robotium Link2, we can run robotium test run from android code.

Now lets talk about uiautomator

i already done following steps manually from Link1

adb push bin/AutomatedTests.jar /data/local/tmp/

Question : How to run bellow line from "Android Activity Code" :

adb shell uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

Case 1:

i tried this code: Code Link, with arguments as bellow

String[] strCmdArgsUiTesting = 
"/system/bin/uiautomator runtest UiTestingExample.jar -c com.intel.vishal.uitestingexample.LaunchBasemarkES2Taiji".split(" ");

Error comes :

INSTRUMENTATION_RESULT: longMsg=Permission Denial: 
Do not have permission in call getContentProviderExternal() 
from pid=2691, uid=10082 
requires android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY

i added this permission to AndroidManifest.xml as bellow

<uses-permission android:name="android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY"/>

but same error comes again. this permission is not working in android activity...

How to solve this error ?

Please Note :- i am using Android 4.2.2

Upvotes: 3

Views: 4438

Answers (2)

VladimirVip
VladimirVip

Reputation: 404

I do believe that your phone needs to be rooted in order to call any console command from the app's Java code...

Upvotes: 3

Aman Gautam
Aman Gautam

Reputation: 3579

Check this link to see how to run a command from android code: Android run bash command in app

Now, you want to execute

uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

instead of

adb shell uiautomator runtest /data/local/tmp/AutomatedTests.jar -c com.example.tests.SimpleTest

Upvotes: 2

Related Questions