python/appium实现华为应用商城app界面上下滑动打开关闭通知栏等功能
生活随笔
收集整理的這篇文章主要介紹了
python/appium实现华为应用商城app界面上下滑动打开关闭通知栏等功能
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
banner=driver.find_element_by_id('com.huawei.appmarket:id/banner_item_image')
ele_size=banner.size
#元素的高度和寬度
ele_height=ele_size['height']
ele_width=ele_size['width']
#獲取元素左上角坐標(biāo)
loc=banner.location
#計(jì)算起點(diǎn)的橫/縱坐標(biāo)
#start_x1=loc['x']+ele_width*0.2
#start_y1=loc['y']+ele_height*0.5
#計(jì)算終點(diǎn)的橫/縱坐標(biāo)
#end_x1=loc['x']+ele_width*0.8
#end_y1=start_x1
#滑動(dòng)方法*
#driver.swipe(start_x, start_y, end_x, end_y)
#滑動(dòng)方法*20(左右滑動(dòng))
#通過(guò)相對(duì)定位屏幕坐標(biāo)的方法,可以適配多種類型
#for i in range(20):#driver.swipe(start_x1,start_y1,end_x1,end_y1)#time.sleep(0.5)#上下滑動(dòng)
start_x=ele_width*0.5
start_y=ele_height*0.8
end_x=start_x
end_y=ele_height*0.2
for i in range(20):driver.swipe(start_x,start_y,end_x,end_y)time.sleep(0.5)
#打開(kāi)通知欄調(diào)用api
driver.open_notifications()
#關(guān)閉通知欄調(diào)用api
time.sleep(2)
#通過(guò)返回鍵關(guān)閉
driver.long_press_keycode(4)
總結(jié)
以上是生活随笔為你收集整理的python/appium实现华为应用商城app界面上下滑动打开关闭通知栏等功能的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 小米应用市场隐私政策
- 下一篇: Web滚动字幕(MARQUEE示例)