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
  • 相关阅读:
    HDU 1452
    POJ 1845
    POJ 2992
    POJ 3358
    POJ 3696
    POJ 3090
    POJ 2478
    2016大连网络赛 Football Games
    2016大连网络赛 Function
    2016大连网络赛 Sparse Graph
  • 原文地址:https://www.cnblogs.com/yijierui/p/13642628.html
Copyright © 2011-2022 走看看