Appium自动化(一)常用的API接口
Appium系列分享,第一篇,常用API接口
1。创建新的会话(session)pythonAndroidfromappiumimportwebdriverdesiredcaps{platformName:Android,platformVersion:7。0,deviceName:AndroidEmulator,automationName:UiAutomator2,app:PATH(pathtoapp)}driverwebdriver。Remote(http:127。0。0。1:4723wdhub,desiredcaps)pythonIOS篇fromappiumimportwebdriverdisapp{platformName:ios,platformVersion:13。3,app:UserslileileiLibraryDeveloperXcodeDerivedDataKnowingLifealgbavbxvxbalpfghgvtdxzyehwrBuildProductsDebugiphonesimulatorKnowingLife。app,automationName:XCUITest,udid:6A367568AE1349A0BEE23B1AD623AB3E,deviceName:iPhone11ProMax}driverwebdriver。Remote(http:0。0。0。0:4723wdhub,disapp)
2。终止会话driver。quit()
3。后退driver。back()
4。屏幕截图screenshotBase64self。driver。getscreenshotasbase64()
5。获得页面源码sourceself。driver。pagesource
6。设置超时driver。setpageloadtimeout(5000)
7。设置隐式等待超时时间driver。implicitlywait(5)
8。设置脚本超时时间driver。setscripttimeout(5000)
9。获取显示方面,横屏竖屏orientationdriver。orientation
10。设置显示方向driver。orientationLANDSCAPE
11。获得地理位置locationdriver。location()
12。设置地理位置driver。setlocation(49,123,10)
13。获得可用的日志类型logtypesdriver。logtypes
14。获得日志对象logsdriver。getlog(driver);
15。记录事件driver。logevent(appium,funEvent)