appium常用方法

2022-02-24 18:48:34 字數 1112 閱讀 9838

1.輸入中文

在capabilities中增加兩項設定:

capabilities.setcapability("unicodekeyboard", "true"); 

capabilities.setcapability("resetkeyboard", "true");

2.傳送文字

driver.findelementbyname("請輸入姓名").sendkeys("請輸入姓名");

3.截圖並儲存至本地 

file screen = driver.getscreenshotas(outputtype.file); 

file screenfile = new file("d:\\screen.png");

try catch (ioexception e)

4.獲取當前介面的activity,可用於斷言是否跳轉到預期的activity 

driver.currentactivity();

5.//開啟通知欄介面 

driver.opennotifications();

6.//獲取網路狀態 

int status = driver.getnetworkconnection().value;

8.安裝apk

public void add1() throws exception

public void add1() throws exception

9.//拖動相機圖示至日曆圖示位置 

new touchaction(driver).longpress(driver.findelementbyname("相機")) 

.moveto(driver.findelementbyname("日曆")).release().perform();

10.啟動系統命令

runtime.getruntime().exec("adb shell am start -w com.aurora.market/com.aurora.market.marketmainactivity");

參考文章:

Appium(五)常用方法

2 用法 1.self.driver.find element by id click 找到元素並點選 1.self.driver.find element by id text找到元素,獲取到當前元素的文字 1.self.driver.find element by id get attribut...

Appium 定位方法

driver.find element by xpath xpath name driver.find element by id id find element by class name是根據class name獲取滿足條件的第乙個元素 driver.find element by class ...

appium定位方法

1.id定位 driver.find element by id 這裡是resource id driver.find element by name 這裡是text 3.class定位 driver.find element by class name class屬性 注 一般乙個頁面上的clas...