zoukankan      html  css  js  c++  java
  • appium 触摸操作

    1、导入模块: from appium.webdriver.common.touch_action import TouchAction

    2、单击控件:tap(self ,element=None, x = None, y = None, count=1),count表示单击的次数

    3、长按控件: long_press(self, el=None,x = None, y = None, duration=1000),duration表示持续的时间,单位毫秒

    from appium import webdriver
    from appium.webdriver.common.touch_action import TouchAction
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    caps = {}
    caps["deviceName"] = "HWJSN-HW"
    caps["automationName"] = "appium"
    caps["platformVersion"] = "10"
    caps["platformName"] = "Android"
    caps["appPackage"] = "com.youdao.dict"
    caps["appActivity"] = ".activity.MainActivity"
    caps["ensureWebviewsHavePages"] = True
    
    driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
    
    #弹窗处理  
    try:
        loc = ("xpath", "//*[@text='始终允许']")
        el = WebDriverWait(driver, 5, 0.5).until(EC.presence_of_element_located(loc))
        TouchAction(driver).tap(el).perform()
    except:
        pass
  • 相关阅读:
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    Python for Data Science
    软件工程实践总结
  • 原文地址:https://www.cnblogs.com/yijierui/p/13642628.html
Copyright © 2011-2022 走看看