您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > appiumpythonapi
AppiumPythonAPI中文版By-HZJAppium·huanzhijin·于6天前发布·最后由huanzhijin于1天前回复·801次阅读根据appium1.4.13.1版本整理Appium_Python_Api文档1.contextscontexts(self):Returnsthecontextswithinthecurrentsession.返回当前会话中的上下文,使用后可以识别H5页面的控件:Usage:driver.contexts用法driver.contexts2.current_contextcurrent_context(self):Returnsthecurrentcontextofthecurrentsession.返回当前会话的当前上下文:Usage:driver.current_context用法driver.current_context3.contextcontext(self):Returnsthecurrentcontextofthecurrentsession.返回当前会话的当前上下文。:Usage:driver.context用法driver.Context4.find_element_by_ios_uiautomationfind_element_by_ios_uiautomation(self,uia_string):FindsanelementbyuiautomationiniOS.通过iOSuiautomation查找元素:Args:-uia_string-TheelementnameintheiOSUIAutomationlibrary:Usage:driver.find_element_by_ios_uiautomation('.elements()[1].cells()[2]')用法dr.find_element_by_ios_uiautomation(‘elements’)5.find_element_by_accessibility_idfind_element_by_accessibility_id(self,id):Findsanelementbyaccessibilityid.通过accessibilityid查找元素:Args:-id-astringcorrespondingtoarecursiveelementsearchusingtheId/NamethatthenativeAccessibilityoptionsutilize:Usage:driver.find_element_by_accessibility_id()用法driver.find_element_by_accessibility_id(‘id’)6.scrollscroll(self,origin_el,destination_el):Scrollsfromoneelementtoanother从元素origin_el滚动至元素destination_el:Args:-originalEl-theelementfromwhichtobeingscrolling-destinationEl-theelementtoscrollto:Usage:driver.scroll(el1,el2)用法driver.scroll(el1,el2)7.drag_and_dropdrag_and_drop(self,origin_el,destination_el):Dragtheoriginelementtothedestinationelement将元素origin_el拖到目标元素destination_el:Args:-originEl-theelementtodrag-destinationEl-theelementtodragto用法driver.drag_and_drop(el1,el2)8.taptap(self,positions,duration=None):Tapsonanparticularplacewithuptofivefingers,holdingforacertaintime模拟手指点击(最多五个手指),可设置按住时间长度(毫秒):Args:-positions-anarrayoftuplesrepresentingthex/ycoordinatesofthefingerstotap.Lengthcanbeuptofive.-duration-(optional)lengthoftimetotap,inms:Usage:driver.tap([(100,20),(100,60),(100,100)],500)用法driver.tap([(x,y),(x1,y1)],500)9.swipeswipe(self,start_x,start_y,end_x,end_y,duration=None):Swipefromonepointtoanotherpoint,foranoptionalduration.从A点滑动至B点,滑动时间为毫秒:Args:-start_x-x-coordinateatwhichtostart-start_y-y-coordinateatwhichtostart-end_x-x-coordinateatwhichtostop-end_y-y-coordinateatwhichtostop-duration-(optional)timetotaketheswipe,inms.:Usage:driver.swipe(100,100,100,400)用法driver.swipe(x1,y1,x2,y2,500)10.flickflick(self,start_x,start_y,end_x,end_y):Flickfromonepointtoanotherpoint.按住A点后快速滑动至B点:Args:-start_x-x-coordinateatwhichtostart-start_y-y-coordinateatwhichtostart-end_x-x-coordinateatwhichtostop-end_y-y-coordinateatwhichtostop:Usage:driver.flick(100,100,100,400)用法driver.flick(x1,y1,x2,y2)11.pinchpinch(self,element=None,percent=200,steps=50):Pinchonanelementacertainamount在元素上执行模拟双指捏(缩小操作):Args:-element-theelementtopinch-percent-(optional)amounttopinch.Defaultsto200%-steps-(optional)numberofstepsinthepinchaction:Usage:driver.pinch(element)用法driver.pinch(element)12.zoomzoom(self,element=None,percent=200,steps=50):Zoomsinonanelementacertainamount在元素上执行放大操作:Args:-element-theelementtozoom-percent-(optional)amounttozoom.Defaultsto200%-steps-(optional)numberofstepsinthezoomaction:Usage:driver.zoom(element)用法driver.zoom(element)13.resetreset(self):Resetsthecurrentapplicationonthedevice.重置应用(类似删除应用数据)用法driver.reset()14.hide_keyboardhide_keyboard(self,key_name=None,key=None,strategy=None):Hidesthesoftwarekeyboardonthedevice.IniOS,use`key_name`topressaparticularkey,or`strategy`.InAndroid,noparametersareused.隐藏键盘,iOS使用key_name隐藏,安卓不使用参数:Args:-key_name-keytopress-strategy-strategyforclosingthekeyboard(e.g.,`tapOutside`)driver.hide_keyboard()15.keyeventkeyevent(self,keycode,metastate=None):Sendsakeycodetothedevice.Androidonly.Possiblekeycodescanbefoundin发送按键码(安卓仅有),按键码可以上网址中找到:Args:-keycode-thekeycodetobesenttothedevice-metastate-metainformationaboutthekeycodebeingsent用法dr.keyevent(‘4’)16.press_keycodepress_keycode(self,keycode,metastate=None):Sendsakeycodetothedevice.Androidonly.Possiblekeycodescanbefoundin发送按键码(安卓仅有),按键码可以上网址中找到:Args:-keycode-thekeycodetobesenttothedevice-metastate-metainformationaboutthekeycodebeingsent用法driver.press_keycode(‘4’)dr.keyevent(‘4’)与driver.press_keycode(‘4’)功能实现上一样的,都是按了返回键17.long_press_keycodelong_press_keycode(self,keycode,metastate=None):Sendsalongpressofkeycodetothedevice.Androidonly.Possiblekeycodescanbefoundin发送一个长按的按键码(长按某键):Args:-keycode-thekeycodetobesenttothedevice-metastate-metainformationaboutthekeycodebeingsent用法driver.long_press_keycode(‘4’)18.current_activitycurrent_activity(self):Retrievesthecurrentactivityonthedevice.获取当前的activity用法print(driver.current_activity())19.wait_activitywait_activity(self,activity,timeout,interval=1):Waitforanactivity:blockuntiltargetactivitypresentsortimeout.ThisisanAndroid-onlymethod.等待指定的activity出现直到超时,in
本文标题:appiumpythonapi
链接地址:https://www.777doc.com/doc-2897981 .html