APPium python 滑屏封裝方法

2021-08-19 16:56:54 字數 1874 閱讀 1753

#!/usr/bin/env python

# coding:utf-8

from time import sleep

#設定路徑資訊

path=lambda p:os.path.abspath(

os.path.join(os.path.dirname(__file__),p)

)global driver

desired_caps =

driver = webdriver.remote('', desired_caps)

def getsize(self):

x = self.driver.get_window_size()['width']

y = self.driver.get_window_size()['height']

return (x,y)

# upper

def swipeup(driver, t=500, n=1):

'''向上滑動螢幕'''

upper= driver.get_window_size()

x1 = upper['width'] * 0.5 # x座標

y1 = upper['height'] * 0.75 # 起始y座標

y2 = upper['height'] * 0.25 # 終點y座標

for i in range(n):

driver.swipe(x1, y1, x1, y2, t)

# lower

def swipedown(driver, t=500, n=1):

'''向下滑動螢幕'''

lower = driver.get_window_size()

x1 = lower['width'] * 0.5 # x座標

y1 = lower['height'] * 0.25 # 起始y座標

y2 = lower['height'] * 0.75 # 終點y座標

for i in range(n):

driver.swipe(x1, y1, x1, y2,t)

# left

def swipleft(driver, t=500, n=1):

'''向左滑動螢幕'''

left = driver.get_window_size()

x1 = left['width'] * 0.75

y1 = left['height'] * 0.5

x2 = left['width'] * 0.05

for i in range(n):

driver.swipe(x1, y1, x2, y1, t)

# right

def swipright(driver, t=500, n=1):

'''向右滑動螢幕'''

right = driver.get_window_size()

x1 = right['width'] * 0.05

y1 = right['height'] * 0.5

x2 = right['width'] * 0.75

for i in range(n):

driver.swipe(x1, y1, x2, y1, t)

if __name__ == "__main__":

print(driver.get_window_size())

sleep(2)

swipeup(driver, n=2)

sleep(2)

swipedown(driver, n=2)

sleep(5)

swipleft(driver, n=2)

sleep(2)

swipright(driver, n=2)

Qt ipad滑屏效果

之前寫過一篇文章 qt 實現滑動切換介面,但是感覺整體還是不夠流暢,不能及時響應使用者的滑動,動畫會有一定的滯後性,最近看到了一種新的方式,可以實現ipad 手機的頁面滑動效果。首先框體面板是自己繪製的,內容區域是繼承自qtablewidget實現的乙個類。qtablewidget往上索引祖先,它繼...

QlistWidget滑屏事件處理

當我們把程式放到移動端上時,比如一體機或者su ce上後,希望qlistwidget是可以滑動的。為了達到此目的,我們需要進行如下設定 1 m listwidget sethorizontalscrollmode qlistwidget scrollperpixel 2 qscroller grab...

移動端滑屏demo

12 34 以上的demo放在具體專案中可能會遇到小問題,例如移動端滑動的還要實現點選到下乙個頁面,就會出現點選先滑動然後才會觸發click。在移動端,手指點選乙個元素,會經過 touchstart touchmove touchend click。手機瀏覽器上,兩次輕觸是放大操作,在第一次被輕觸後...