• appium python实例脚本1


    #coding=utf-8
    import os, time, unittest
    from appium import webdriver

    PATH = lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))

    desired_caps = {}
    desired_caps['platformName'] = 'Android' # 设备系统
    desired_caps['platformVersion'] = '4.3' # 设备系统版本
    desired_caps['deviceName'] = '3230df4ba1c6cfd3' # 设备名称

    desired_caps['app'] = PATH(r"/Users/xxx/Downloads/xxx.apk")
    desired_caps['appPackage'] = 'com.cn.xxx'
    desired_caps['appActivity'] = 'com.cn.xxx.activity.splash.SplashActivity'

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

    #休眠10s等待程序启动
    time.sleep(10)
    print ("aaaaaaa")

    #获取页面长宽
    def getSize():
    x = driver.get_window_size()['width']
    y = driver.get_window_size()['height']
    return (x, y)

    #屏幕向左滑动
    def swipLeft(t):
    l=getSize()
    x1=int(l[0]*0.75)
    y1=int(l[1]*0.5)
    x2=int(l[0]*0.05)
    driver.swipe(x1,y1,x2,y1,t)

    #调用向左滑动
    swipLeft(1000)
    time.sleep(5)
    #调用向左滑动
    swipLeft(1000)
    #调用向左滑动
    time.sleep(5)
    swipLeft(1000)
    time.sleep(5)

    driver.find_element_by_id('com.cn.xxx:id/tv_go').click()
    time.sleep(5)
    driver.find_element_by_id('com.cn.xxx:id/btn_continue').click()
    time.sleep(5)
    driver.find_element_by_id('com.cn.xxx:id/btn_move').click()

  • 相关阅读:
    虚拟主机wordpress文件上传大小限制更改
    wordpress网站迁移
    JavaScript算法相关
    文章阅读(三)
    文章阅读(二)
    Image():强制让图片缓存起来
    JavaScript运算符与类型
    JavaScript权威指南--多媒体和图形编程
    JavaScript权威指南--脚本化HTTP
    JavaScript权威指南--事件处理
  • 原文地址:https://www.cnblogs.com/sgwjj/p/7594316.html
Copyright © 2020-2023  润新知