**:
private
androiddriver
driver
;@before
public
void
setup
()throws
exception
@after
public
void
teardown
()throws
exception
2.截圖並儲存至本地
file
screen
=driver
.getscreenshotas
(outputtype
.file
);file
screenfile
=new
file
("d:\\screen.png"
);try
catch
(ioexceptione)
3.push檔案、pull檔案
file
file
=new
file
("d:\\test.txt"
);內容為"testerhome"
string
content
=null
;try
catch
(ioexceptione)
byte
data
=base64
.encodebase64
(content
.getbytes
());
driver
.pushfile
("sdcard/test.txt"
,data
);byte
resultdate
=driver
.pullfile
("sdcard/test.txt"
);system
.out
.println
(new
string
(base64
.decodebase64
(resultdate
)));
//列印結果為"testerhome"
4.
//獲取當前介面的activity,可用於斷言是否跳轉到預期的activity
driver
.currentactivity
();
5.
//開啟通知欄介面
driver
.opennotifications
();
6.
//獲取網路狀態
intstatus
=driver
.getnetworkconnection
().value
;system
.out
.println
(status
);//設定網路狀態
driver
.setnetworkconnection
(new
networkconnectionsetting
(status
));//或者
driver
.setnetworkconnection
(new
networkconnectionsetting
(false
,true
,false
));
7.
driver
.startactivity
("com.android.camera"
,".cameralauncher"
);8.
//自動滑動列表
driver
.scrollto
("text"
);//或者
driver
.scrolltoexact
("text"
);
9.拖動元素
//拖動相機圖示至日曆圖示位置
newtouchaction
(driver
).longpress
(driver
.findelementbyname
("相機")).
moveto
(driver
.findelementbyname
("日曆"
)).release
().perform
();
10.圖案解鎖,解鎖該圖案:
整點 appium 中部分 api 的使用方法
private androiddriver driver before public void setup throws exception after public void teardown throws exception 2.截圖並儲存至本地 file screen driver getsc...
Appium常用的API函式
1 獲取預設系統語言對應的strings.xml檔案內的資料。2 查詢某乙個語言環境對應的字串檔案strings.xml內資料。3 獲取當前activity,比如 apidemos current activity 1 根據bundleid來判斷該應用是否已經安裝 中代表的是包名,而在ios中有專門...
appium 測試使用的API
模擬操作類 元素定位類findelementbyxx driver.findelementbyid id id獲取方法 利用uiautomater截圖,獲取resource id driver.findelementbyclassname classname 通常通過這種方式獲取的view不止乙個,...