美文网首页
appium 1.7 以上 swipe 滑动不支持

appium 1.7 以上 swipe 滑动不支持

作者: 夏树的宝马 | 来源:发表于2018-01-02 19:03 被阅读1298次

试了一下午,发现appium的swipe函数不能滑动,网上说已经不支持这个函数。
看了大佬的博客发现其实支持的,只是需要传入时间不能传入数字

from appium import webdriver
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
# from selenium import webdriver
from datetime import timedelta

chrome_options_h5={'androidProcess': 'com.tencent.mm:tools'}
desired_caps = {
                'platformName': 'Android',
                #本机
                # 'deviceName': 'A02AECP8256TU',
                # 'platformVersion': '7.0',
                'deviceName': '12b8a7ca',
                'platformVersion': '5.0.2',
                # 'browserName':'Chrome',
                'noReset':'true',
                # 'appPackage': ' com.codemao.box',
                # 'appActivity': 'com.codemao.box.module.welcome.FirstActivity',
                'appPackage': ' com.tencent.mm',
                'appActivity': '.ui.LauncherUI',
                'unicodeKeyboard':'true',
                'resetKeyboard':'true',
                # 'chromedriverExecutable':"C:\Program Files\Python35\chromedriver.exe",
                # 'automationName':'appium',
                # 微信h5
                'chromeOptions':chrome_options_h5
                }


dr=webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
print('1')
sleep(5)
dr.find_element_by_xpath("//*[@text='发现']").click()
print('2')
width=dr.get_window_size().get('width')
height=dr.get_window_size().get('height')
print(width)
print(height)
# 滑动功能
dr.swipe(int(width)/2,int(height)/2,int(width)/2,int(height)/4,duration=sleep(1))
sleep(2)
dr.find_element_by_xpath("//*[@text='小程序']").click()
sleep(3)
dr.find_element_by_xpath("//*[contains(@text, '美团外卖')]").click()
sleep(6)
print(dr.contexts,'所有contexts')
print(dr.current_context,'当前的')


参考大佬文章:
http://blog.csdn.net/achang21/article/details/78167793

相关文章

网友评论

      本文标题:appium 1.7 以上 swipe 滑动不支持

      本文链接:https://www.haomeiwen.com/subject/xmuqnxtx.html