android-uiautomator

Android revoke permission at start of each test

跟風遠走 提交于 2019-12-08 15:00:56
问题 I'm using Espresso and UIAutomator to write my test cases. I'm testing external storage permissions when it's denied and when it's allowed. I have different test cases which all require the permission to be revoked at the start of the test case. However, some of the test cases should and do result in the permission being granted, so I need to revoke the permission when the next test is being executed. I have searched around and the closest thing I came across is using the pm manager to

How to scroll to specific element inLatest version of Appium using Java?

余生长醉 提交于 2019-12-08 11:08:42
问题 My element is not visible on screen but when i use .isDisplayed() method i get true my code is as below Point xy = send_mail.getCoordinates().onScreen(); int a=xy.getX(); int b =xy.getY(); System.out.println("a" + xy.getX() + "b" + xy.getY()); TouchAction touchAction = new TouchAction(driver); touchAction.moveTo(a, b); send_mail is xpath of element to be found. This is tracelog help! I cannot use while loop to iterate until element is not displayed as it it considered visible y appium. java

Writing to Android UI Automator output console

纵饮孤独 提交于 2019-12-06 23:48:49
问题 I am writing a small wrapper over Android UI Automator. Normally we can see the test case status in the console. Can I access it and add my own messages? I have tried System.out.println . But it did not work. Is there any way of doing this? 回答1: You can use Instrumentation.sendStatus(..) report information to the console. sendStatus(..) takes a Bundle and a status code as arguments. It won't let you write a string directly to the console, but each key / value pair in the Bundle will be

Unable to start uiautomatorviewer

匆匆过客 提交于 2019-12-06 19:42:18
问题 I have : Android SDK Tools, Revision 22 Android SDK Platform, API 18 I go to <android-sdk>/tools/ , I see there is one file named " uiautomatorviewer ", I execute command uiautomatorviewer from terminal under the above path, however I got the following message: uiautomatorviewer: command not found why? 回答1: Because your tools/ directory is not in your PATH . Either use ./uiautomatorviewer or add tools/ (and probably platform-tools/ to your PATH . Note that this has nothing to do with

Multiple devices connected error in Robotframework

此生再无相见时 提交于 2019-12-06 14:48:49
问题 I am using Robot Framework with UI-Automator for automating Native Android application. In my current instance I have connected two devices to my PC- one for my general testing work and in the second device, I am running Automation. I have given serial of the device while running the test cases. But I am getting following error in the console: EnvironmentError: Multiple devices attached but default android serial not set can somebody help me what I need to do. 回答1: The answer is on the

Integrating uiautomator test case with application code in Android

北城以北 提交于 2019-12-05 21:22:20
I am using Eclipse IDE. Here is my code for uiautomator testcase: public class caltest extends UiAutomatorTestCase { public void testDemo() throws UiObjectNotFoundException, IOException { //mytesstcode } } To run this test i have to issue following commands from command line: /tools/android create uitest-project -n -t 1 -p Go to the project directory where your build.xml file is located and build your test JAR. ---> ant build Deploy your generated test JAR file to the test device by using the adb push command: ---> adb push /data/local/tmp/ ---> adb shell uiautomator runtest jarname.jar -c

UI Automator Viewer: receiving “Error taking device screenshot: null” every time from AVD device

我只是一个虾纸丫 提交于 2019-12-05 20:01:21
问题 This only happends on the AVD devices within the AVD manager. I never get this error when capturing uiautomatorviewer screenshots from Genymotion. When attempting to capture within the Android Device Monitor in AS...it gives me a little more detail: Reason: Error obtaining UI hierarchy 回答1: Try it with HAXM acceleration turned off, if you can. I had to run the test using a profile that then ran the test on a physical device to get the screen shots. Essentially, if the AVD has Use GPU or

Need to identify xpath for android element using appium

折月煮酒 提交于 2019-12-05 17:36:22
问题 I am testing my Android application using Appium framework. I have an android screen that doesn't have ids for its views (and I don't want to add...), so I thought using Xpath. This is how the screen looks like in UI Automator Viewer : I want to get all the relative layouts (marked in red - sixteen items) I tried the following: List<WebElement> webElementslist = mAppDriver.findElementsByXPath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]

UiAutomator getLastTraversedText()

主宰稳场 提交于 2019-12-05 04:09:18
I was trying to test an Android Webview using Android UiAutomator. As I understand the documentation , scrolling through a WebvView would generate UI traversal events, and those should be readable via getUiDevice().getLastTraversedText(). However, when I use getUiDevice().pressDPadDown() to scroll through a web view, getUiDevice().getLastTraversedText() keeps returning null. What have I missed? If anyone has gotten this call to work I would very much appreciate a short code sample. JulianHarty Bad news: I've spent several hours trying to fathom out how to get this working, however I've yet to

Writing to Android UI Automator output console

社会主义新天地 提交于 2019-12-05 03:26:28
I am writing a small wrapper over Android UI Automator. Normally we can see the test case status in the console. Can I access it and add my own messages? I have tried System.out.println . But it did not work. Is there any way of doing this? You can use Instrumentation.sendStatus(..) report information to the console. sendStatus(..) takes a Bundle and a status code as arguments. It won't let you write a string directly to the console, but each key / value pair in the Bundle will be written out like this: INSTRUMENTATION_STATUS: key1=value1 INSTRUMENTATION_STATUS: key2=value2 INSTRUMENTATION