环境:
系统:ios 10.13.6 (17G12034)
appium:1.14.0
xcode:10.1
iphone:iphone7 12.4
1、下拉刷新(顶部)
def drag(ele,time):
'''
下拉操作
:param ele:
:param time:
:return:
'''
a = 0.5
b1 = 70 / 667
b2 = 450 / 667
# 获取当前手机屏幕大小X,Y
X = driver.get_window_size()['width']
Y = driver.get_window_size()['height']
# 屏幕坐标乘以系数即为用户要点击位置的具体坐标
driver.execute_script("mobile:dragFromToForDuration",
{"duration": time, "element": ele, "fromX":a * X , "fromY": b1 * Y, "toX": a * X,
"toY": b2 * Y})
调用:
# 下拉分享
drag(geteleById("租房"),0.4)
2、输入框输入后收起键盘
这里当初尝试了各种方法都没有效果,包括hideKeyboard(),特别是唤起数字键盘之后,键盘一直收不起来
之后在另一个博客里看到了在输入完成后再输入"\n"就可以了 运行有效
参考:https://blog.csdn.net/hxy199421/article/details/87260772
sendkeyseleByPredicate("type == 'XCUIElementTypeTextField' AND value == '请填写电话号码'","13501500555\n")