Appium android4.3 中增强了自动化测试和分析

思寒_seveniruby · 2013年12月25日 · 577 次阅读

详细请看 http://developer.android.com/about/versions/android-4.3.html
感觉非常重要.

Testing and Debugging
Automated UI testing

The new UiAutomation class provides APIs that allow you to simulate user actions for test automation. By using the platform's AccessibilityService APIs, the UiAutomation APIs allow you to inspect the screen content and inject arbitrary keyboard and touch events.

To get an instance of UiAutomation, call Instrumentation.getUiAutomation(). In order for this to work, you must supply the -w option with the instrument command when running your InstrumentationTestCase from adb shell.

With the UiAutomation instance, you can execute arbitrary events to test your app by calling executeAndWaitForEvent(), passing it a Runnable to perform, a timeout period for the operation, and an implementation of the UiAutomation.AccessibilityEventFilter interface. It's within your UiAutomation.AccessibilityEventFilter implementation that you'll receive a call that allows you to filter the events that you're interested in and determine the success or failure of a given test case.

To observe all the events during a test, create an implementation of UiAutomation.OnAccessibilityEventListener and pass it to setOnAccessibilityEventListener(). Your listener interface then receives a call to onAccessibilityEvent() each time an event occurs, receiving an AccessibilityEvent object that describes the event.

There is a variety of other operations that the UiAutomation APIs expose at a very low level to encourage the development of UI test tools such as uiautomator. For instance, UiAutomation can also:

Inject input events
Change the orientation of the screen
Take screenshots
And most importantly for UI test tools, the UiAutomation APIs work across application boundaries, unlike those in Instrumentation.
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册