appium w3c滑动页面
时间: 2023-08-31 21:13:00 浏览: 128
使用Appium进行W3C标准的页面滑动可以通过以下步骤实现:
1. 获取屏幕大小
```
size = driver.get_window_size()
```
2. 计算滑动起始点和终止点的坐标
```
start_x = size['width'] * 0.5
start_y = size['height'] * 0.8
end_x = size['width'] * 0.5
end_y = size['height'] * 0.2
```
此处以向上滑动为例,起始点为屏幕中央的下方,终止点为屏幕中央的上方。
3. 执行滑动操作
```
action = TouchAction(driver)
action.press(x=start_x, y=start_y).wait(200).move_to(x=end_x, y=end_y).release().perform()
```
其中wait(200)表示等待200毫秒,让页面有足够的时间响应滑动操作。
完整的代码示例:
```
from appium.webdriver.common.touch_action import TouchAction
size = driver.get_window_size()
start_x = size['width'] * 0.5
start_y = size['height'] * 0.8
end_x = size['width'] * 0.5
end_y = size['height'] * 0.2
action = TouchAction(driver)
action.press(x=start_x, y=start_y).wait(200).move_to(x=end_x, y=end_y).release().perform()
```
阅读全文