http://blog.csdn.net/deadgrape/article/details/50585677
通過前幾篇的講述,我相信大家已經對RF+Appium的框架已經有所了解了。
接下來我告訴大家一些關於AppiumLibrary函數的用法。
1. 點擊按鈕:
Click Button | index_or_name | Click button |
實例:Click Button index=0
作者通過實驗發現在安卓手機應用測試中,name這個屬性不起作用,所以建議還是使用index屬性。
2.輸入內容:
Input Text | locator, text | Types the given text into text field identified by locator. See introduction for details about locating elements. |
實例:Input Text id=com.tencent.mm:id/ayc 測試賬號
作者通過實驗發現安卓手機應用測試中,有許多ID相同的控件,從而定位控件只能通過XPATH來定位,不知道XPATH的同學們不用着急,在后面的篇章我會告訴大家如何用XPath來定位元素。
3.滑動屏幕:
Swipe | start_x, start_y, end_x, end_y, duration=1000 | Swipe from one point to another point, for an optional duration. |
實例: Swipe 50 100 100 100 duration=2000
作者的例子為橫向滑動50dp,滑動時間為2秒,科普:手機的原點即(0,0)為屏幕的左上角,如果手機屏幕分辨率為480*720的,則右下角的坐標為(480,720)。
4.放大元素:
Zoom | locator, percent=200%, steps=1 | Zooms in on an element a certain amount. |
實例: Zoom id=com.tencent.mm:id/ayc percent=150% steps=1
作用為將一個元素一次性放大1.5倍。
恩,最實用的幾個函數已經告訴大家了,我相信通過這4個函數已經可以模擬絕大部分對手機的操作了,在之后的篇章中我會告訴大家關於校驗操作、等待操作、絕對坐標操作、以及一些實用小技巧。