zoukankan      html  css  js  c++  java
  • 慕课网页面app的滑动

    #coding=utf-8
    from appium import webdriver

    def get_driver():
    desc={
    "platformName":"Android",
    "platformVersion":"5.1.1",
    "deviceName":"emulator-5554",
    "appPackage":"cn.com.open.mooc",
    "appActivity":".index.splash.GuideActivity"

    }
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desc)
    return driver

    # desc['platformName']='Android'
    # 手机版本
    # desc['platformVersion']='5.1.1'
    # 手机唯一标识
    # desc['deviceName'] = 'emulator-5554'
    # 包名
    # desc['appPackage'] = 'cn.com.open.mooc'
    # 入口
    # desc['appActivity'] = '.index.splash.GuideActivity'
    #True 重置
    # desc['noReset']=True
    #重置输入法
    # desc['unicodeKeyboard']=True
    #appium的输入法
    # desc['resetKeyboard']=True
    # driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desc)


    #获取屏幕的宽高
    def get_size():
    size=driver.get_window_size()
    width=size['width']
    height=size['height']
    return width,height
    #向左滑动
    def swipe_left():
    x1=get_size()[0]/10*9
    y1=get_size()[1]/2
    x2=get_size()[0]/10
    driver.swipe(x1,y1,x2,y1)
    #向右滑动
    def swipe_right():
    x1=get_size()[0]/10
    y1=get_size()[1]/2
    x2=get_size()[0]/10*9
    driver.swipe(x1,y1,x2,y1)
    #向上滑动
    def swipe_up():
    x1=get_size()[0]/2
    y=get_size()[1]/10*9
    y1=get_size()[0]/10
    driver.swipe(x1,y,x1,y1)
    #向下滑动
    def swipe_down():
    x1=get_size()[0]/2
    y=get_size()[1]/10
    y1=get_size()[1]/10*9
    driver.swipe(x1,y,x1,y1)
    def swipe_on(direction):
    if direction=='up':
    swipe_up()
    elif direction=='down':
    swipe_down()
    elif direction=='left':
    swipe_left()
    else:
    swipe_right()



    # get_size()
    # swipe_left()
    driver=get_driver()
    swipe_on('left')
  • 相关阅读:
    flex 遍历Object或者JSON对象内容的实现代码
    Flex Vector使用(转)
    Flex——Array,ArrayCollection,Vector性能比较(转)
    SQLSERVER远程备份、恢复(转)
    隐藏Jquery dialog 按钮
    GSM 短信相关AT指令(转)
    SQL Server 父子迭代查询语句,树状查询(转)
    js framework comparation
    eventEmitter
    调试 shell script 方法
  • 原文地址:https://www.cnblogs.com/xuzhongtao/p/9758529.html
Copyright © 2011-2022 走看看