Appium定位之手机特有操作

编程入门 行业动态 更新时间:2024-10-08 02:19:00

Appium定位之手机特有<a href=https://www.elefans.com/category/jswz/34/1770947.html style=操作"/>

Appium定位之手机特有操作

  1. 滑动操作

     

 思路:

1.点击取消更新,不点击跳过

2.获取屏幕尺寸

3.x1>x2,y1=y2

x1=屏幕尺寸的宽*0.9

x2=屏幕尺寸的宽*0.1

y1=y2=y*0.5

# -*- codeing = utf-8 -*-
# @Time : 2022/3/31 19:52
# @Author :su
# @File : ky_left_slip.py
# @Software : PyCharm
from time import sleepfrom testcase.kyCapability import check_cancelBtn, kydriver#公共业务
check_cancelBtn()#定义函数,获取屏幕尺寸
def get_size():x = kydriver.get_window_size()['width']y = kydriver.get_window_size()['height']print(x,y)return x,y
get_size()#定义函数,滑动操作
def swipeLeft():ll = get_size()#ll[0]代表屏幕尺寸x轴#ll[1]代表屏幕尺寸y轴x1 = int(ll[0]*0.9)x2 = int(ll[0]*0.1)y1 = int(ll[1]*0.5)y2 = y1# 5个参数# 第一个和第二个:起始坐标# 第三个和第四个:结束坐标# 第五个:滑动消耗的时间毫秒kydriver.swipe(x1,y1,x2,y2,1000)# 滑动两次
for i in range(2):swipeLeft()sleep(1)

2. 拖动操作

TouchAction(webdriver)对象,提供方法:

  • press():按压某一个坐标点(x,y)
  • tap():点击
  • longpress():长按压
  • move_to():移动坐标点
  • wait():等待时间操作
  • release():释放
  • perform():执行

举例:九宫格解锁

# -*- codeing = utf-8 -*-
# @Time : 2022/3/31 20:24
# @Author :su
# @File : suishouji_touchAction.py
# @Software : PyCharm
from appium import webdriverdesired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '9'
desired_caps['deviceName'] = '127.0.0.1:62025'
#安装app
desired_caps['app'] = r'F:\mymoney.apk'
desired_caps['appPackage'] = 'com.mymoney'
desired_caps['appActivity'] = 'com.mymoney.biz.splash.SplashScreenActivity'
desired_caps['noReset'] = 'false'
# webdriver对象连接appium服务端
modriver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)

更多推荐

Appium定位之手机特有操作

本文发布于:2024-03-15 00:46:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1737735.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   手机   Appium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!