uiautomator
Python wrapper of Android uiautomator test tool.
In KitKat we were able to get webview view hierarchy from a UIAutomator dump if focus was placed on the webview. I was wondering if there was substitute functionality for getting webview view hierarchy with the lollipop release, or if that functionality was lost in the release?
Source: (StackOverflow)
Is it possible for the uiautomator to select a password EditText? I have no problem finding other EditText views by their android:hint property, but the uiautomatorviewer shows all password fields as NAF. I tried setting the password field content description and that didn't work either.
If it's not possible, how do you set a timeout for a tester to manually enter a password?
Source: (StackOverflow)
From what I can see, when a UIAutomator script is compiled into a jar file and it gets run by using the adb shell command. I can see that there is a -e debug command line option which waits for a debugger to connect before starting but how do I connect this to the debugger from Eclipse so I can debug my UI Automator script?
Source: (StackOverflow)
I'm trying to implement an UIAutomator testcase with a general method to perform a click on a ListView item (regardless of the type of viewgroup holding the listitem).
Currently I have following code, but it keeps on clicking the first item.
public void clickListViewItem(int index) throws UiObjectNotFoundException {
UiObject listview = new UiObject(new UiSelector().className("android.widget.ListView"));
if(index <= listview.getChildCount()){
listview.getChild(new UiSelector().index(index)).click();
}else{
throw new UIObjectNotFoundException("Index is greater than listSize");
}
}
Source: (StackOverflow)
I am creating an automation test project in which I have issue to select the item from the AutoCompleteTextView.
You can see the snap and the views[all expanded] it has. The dropdown of the AutoCompleteTextView does not appear in view tree nor I am able to select using mouse.
I have tried below approaches to select the item form from the AutoCompleteTextView adapter:
UiScrollable locationList = new UiScrollable(new UiSelector().scrollable(true));
locationList.scrollTextIntoView(location);
UiScrollable locationList = new UiScrollable(locationEditText.getSelector());
locationList.scrollTextIntoView(location);
Here locationEditText is my AutoCompleteTextView
UiObject selectedLocation = locationList.getChild(new UiSelector().text(location));
selectedLocation.click();
from the locationList it does not select the item with the string passed.
editLocationResId = "android:id/text1";
UiObject selectedLocation = new UiObject(new UiSelector().resourceId(editLocationResId));
selectedLocation.click();
The id from the adpter textview does not work either.
Can anybody help me with selecting the item from the AutoCompleteTextView in uiautomator? Or the more approaches get the desire output.
Source: (StackOverflow)
I'm trying to identify the parent view of an ui element so I can navigate through the UI freely.
For example, in Settings app, I can find the view with the text "Bluetooth":
UiObject btView = new UiObject(new UiSelector().text("Bluetooth"));
Now, the part where I get stuck is this one: I want to navigate two levels up and start a new search for the on/off button that enables and disables bluetooth.
Note: I can get the button if I use the code below.
UiObject btButtonView = new UiObject(new UiSelector().className("android.widget.Switch").instance(1));
This searches for switch buttons and returns the second encounter. I want the search to be more precise and look for the button in the linear layout that contains the "Bluetooth" text.
UPDATE:
This is the layout of the Settings app (the Bluetooth part that I need):
LinearLayout
LinearLayout
ImageView
RelativeLayout
TextView (with text = "Bluetooth")
Switch ()
Source: (StackOverflow)
I know that this question is popular, but no one of solutions can help me.
I used this, this, this and this solutions, but no one help me.
I want to implement uiautomator Tests and need to build my build.xml with ant, but get this strange error.
I use Windows 8.1
My JAVA_HOME system variable set to c:\programs files\java\jdk1.7.0_51 and to c:\programs files(x86)\java\jdk1.7.0_51
My PATH system variable set also to %JAVA_HOME%/bin, my %ANT_HOME% is set to c:\apache-ant.
But when I execute ant build in the android app derictory I get the
unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar
BUILD FAILED
Perhaps JAVA_HOME does not point to the JDK
But my JAVA_HOME points to right JDK ! I confused with this. I also rebuild my build several times, I've got the same.
Will be glad if somebody help me.
Source: (StackOverflow)
I am trying to write an Android application/service which can be deployed on the target device. The app can be used as a hook to remotely control a target device. Starting from Jelly Bean release, there is the UI Automator implementation available, which provides similar functionality. However, it seems that UI Automator can only be used via ADB interface. Application running on the device cannot use UI Automator directly(???). I am trying to find a solution that can work without the help of the ADB. For example, the hook can listen on a socket as a protobuf server. The client can send command to the hook to remotely control and device. I looked into the Andorid SDK source code. It looks like the only way is to use android accessibility APIs. I am wondering if there is any better way?
Source: (StackOverflow)
recent i tryied getting started with android uiautomation testing.
The tutorial from the developer site i've worked through a few times and after having some problems and solving them now i have got a bigger issue i can't solve on my own...
I created a project, imported the two jar files and builded a java testcase scenario (the one from the tutorial.)
after that i created an uitest projekt with shell command line. updated the build.xml created a jar file and pushed it onto my device.
As far as good everything worked nicely upon this point.
But tryin to run my tests with the command line :
adb -s shell uiautomator runtest DeviceUnlocker.jar -c c.d.d.DeviceUnlocker
i only get the error:
INSTRUMENTATION_RESULT: shortMsg = java.lang.RuntimeException
INSTRUMENTATION_RESULT: longMsg=Didn't find class "c.d.d.DeviceUnlockingPseudoCodeTest on Path: /system/framework/android.test.runner.jar: /system/framework/uiautomator.jar:: /data/local/tmp/DeviceUnlocker.jar
INSTRUMENTATION_CODE: 0
i've been googeling for a few days now and i've found no solution for this problem.
does anyone have an idea for my problem?
Regards
Source: (StackOverflow)
Does anyone try the android UITesting
framework UIAutomator
?
When I use the class UiScrollabl
" to find some objects in a scrollable object, it can't find the object if the the length of the scrollable object is too long(need to swipe twice to find it), like "Developer options" in the "Settings" app.
Does anyone have the same issue?
Source: (StackOverflow)
When I work with tests - I add class in special module and run test configuration. Class extend (for example) TestCase and work well.
But when I extend UiAutomatorTestCase - I get error
java.lang.RuntimeException: Stub!
at com.android.uiautomator.testrunner.UiAutomatorTestCase.<init> (UiAutomatorTestCase.java:5) ...
My simple class:
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class AutoTest extends UiAutomatorTestCase {
public void testSome() throws UiObjectNotFoundException {
getUiDevice().pressHome();
}
}
How to run it in Android Studio IDE?
Source: (StackOverflow)
I have my uiautomator test case:
public class clickTest extends UiAutomatorTestCase {
public void myTest() throws UiObjectNotFoundException {
...
//Is it possible to get Context or Activity here?
}
}
I am wondering, is it possible to get Context
or Activity
instance in UiAutomatorTestCase
?
Or How to get PackageManager
in UiAutomatorTestCase
?
Source: (StackOverflow)
When playing with the Android uiAutomator I've run into an issue when trying to run the tests on a 4.1.2 device.
When using the code from the enter link description here an exception is thrown when attempting to scroll the apps tray.
I originally thought it was caused by compiling against api 17 rather than 16 but that doesn't seem to be true.
Anyone else encountered this?
Exception raised:
[exec] java.lang.reflect.InvocationTargetException
[exec] at java.lang.reflect.Method.invokeNative(Native Method)
[exec] at java.lang.reflect.Method.invoke(Method.java:511)
[exec] at com.example.runTests(Runner.java:124)
[exec] at com.example.testExecutor(Runner.java:60)
[exec] at java.lang.reflect.Method.invokeNative(Native Method)
[exec] at java.lang.reflect.Method.invoke(Method.java:511)
[exec] at junit.framework.TestCase.runTest(TestCase.java:168)
[exec] at junit.framework.TestCase.runBare(TestCase.java:134)
[exec] at junit.framework.TestResult$1.protect(TestResult.java:115)
[exec] at junit.framework.TestResult.runProtected(TestResult.java:133)
[exec] at junit.framework.TestResult.run(TestResult.java:118)
[exec] at junit.framework.TestCase.run(TestCase.java:124)
[exec] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:124)
[exec] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:85)
[exec] at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:76)
[exec] at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
[exec] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[exec] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
[exec] at dalvik.system.NativeStart.main(Native Method)
[exec] Caused by: java.lang.NoSuchMethodError: com.android.uiautomator.core.UiScrollable.setAsHorizontalList
[exec] at com.example.Runner.launchAppFromHomeScreen(Test.java:45)
[exec] ... 19 more
Source: (StackOverflow)
I am trying to validate text in each list item in my ListView and scroll down one by one so I can validate each one... but for some reason I cant get it to continue scrolling through the list validating each element. Has anyone had any luck automating this kind of action.Here is the closest I can come to.
Please let me know if this isn't enough info:
UiScrollable scrollableList = new UiScrollable(new UiSelector()
.resourceId("com.example.app:id/listView")
.className(android.widget.ListView.class.getName())
.index(3));
for ( i = 0; i < 100; i++ ) {
UiObject listItem = scrollableList.getChildByText(new UiSelector()
.className("android.widget.RelativeLayout")
.instance(i), "Text Title");
UiObject textBody = listItem.getFromParent(new UiSelector()
.resourceId("com.example.app:id/textBody"));
System.out.println("Validating: " + textBody.getText());
There are only 5 listItems visible on the screen at the time, so it fails when it tries to get to number 6, which it cant because:
a. it wont try to scroll forward to get the next one in the list
b. even if it did scroll forward to get the next one in the list, the instance value will decrease to 5, instead of increasing to 6.
I have tried it without the .instance() method, but in that case it just loops over the first item in the list over and over without progressing to item 2,3,4 ect.
If anyone has come across this issue, I would love feedback.
Source: (StackOverflow)
There seem to be a decent number of questions about adding external jars to android projects and ant projects, but I'm not finding out a solution that works in this instance. I'm not too familiar with Ant, which probably exasperates the problem.
Problem is: I'm trying to add JSch libraries to my uiautomator project. I put the jsch.jar file into the /libs folder in hopes it would be found by 'android create uitest-project'. However, not the case - so it seems I need to modify build.xml/ant.properties/build.properties or something to get ant to find the jar
Specific error is:
[javac] Compiling 5 source files to /Users/.../KeyEvents/bin/classes
[javac] /Users/.../KeyEvents/src/com/proj/automation/core/coreSSH.java:9: error: package com.jcraft.jsch does not exist
The build.xml is created by the android script, and Ant is used out of the box - so I think my scrub-knowledge of ant is the issue :P.
Source: (StackOverflow)