zoukankan      html  css  js  c++  java
  • 学习笔记2:appium 滑动方法封装

    # coding:utf-8
    from appium import webdriver

    desired_caps = {
    "platformName": "Android",
    "deviceName": "2392d777", # 通过adb devices命令获取
    "platformVersion": "7.1.2",
    "appPackage": "包名", # 根据所测试app的值填写
    "appActivity": "appActivity", # 根据所测试app的值填写
    "noReset": False,
    "unicodeKeyboard": True,
    "resetKeyboard": True,
    }

    driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

    def swipeUp(driver, duration=500, t=1):
    # 向上滑动屏幕
    a = driver.get_window_size()
    start_x = a['width']/2
    start_y = a['height']/5*4
    end_x = a['width']/2
    end_y = a['height']/5*1
    for i in range(t):
    driver.swipe(start_x, start_y, end_x, end_y, duration)

    def swipeDown(driver, dutation=500, t=1):
    # 向下滑动屏幕
    a = driver.get_window_size()
    start_x = a['width']/2
    start_y = a['height']/5*1
    end_x = a['width']/2
    end_y = a['height']/5*4
    for i in range(t):
    driver.swipe(start_x, start_y, end_x, end_y, dutation)

    def swipeRight(driver, dutation=500, t=1):
    # 向左滑动屏幕
    a = driver.get_window_size()
    start_x = a['width']/5*4
    start_y = a['height']/2
    end_x = a['width']/5*1
    end_y = a['height']/2
    for i in range(t):
    driver.swipe(start_x, start_y, end_x, end_y, dutation)

    def swipeLeft(driver, dutation=500, t=1):
    # 向右滑动屏幕
    a = driver.get_window_size()
    start_x = a['width']/5*1
    start_y = a['height']/2
    end_x = a['width']/5*4
    end_y = a['height']/2
    for i in range(t):
    driver.swipe(start_x, start_y, end_x, end_y
    , dutation)
    if __name__ == '__main__':
    swipeUp(driver, t=3)
  • 相关阅读:
    Sort函数的用法
    hdu 1087 Super Jumping! Jumping! Jumping!(最大上升子序列和)
    hdu 1159 Common Subsequence(LCS)
    最长公共子序列
    蓝桥杯 -- 取字母
    蓝桥杯 -- 串的处理
    蓝桥杯 -- 奇怪的比赛
    蓝桥杯 -- 微生物繁殖
    hdu 1159 Common Subsequence(最长公共子序列)
    hdu 2458 Kindergarten
  • 原文地址:https://www.cnblogs.com/xiaoxin-test/p/10361800.html
Copyright © 2011-2022 走看看