zoukankan      html  css  js  c++  java
  • 3.Appium滑动函数swipe

    Appium滑动函数

    滑动的优点: 是边滑动边寻找目标元素

    缺点是:兼容性不行,不同的屏幕分辨率不一样

    Appium处理滑动方法是swippe

    滑动API:wipe(self: T, start_x: int, start_y: int, end_x: int, end_y: int, duration: int = 0)

    int startx _开始滑动的x坐标

    int starty _开始滑动的y坐标

    int endx _结束点x坐标

    int endy _结束点y坐标

    duration 滑动时间(默认5毫秒)

    屏幕左上角为起点,坐标为(0,0),起点往右为Y轴,起点以下为X轴

    下面是滑动boss直聘的岗位

    
        #设置底层测试驱动-1.15默认使用的底层驱动就是UiAutomator2
        'automationName':'UiAutomator1',#或者UiAutomator1
        #'skipServerInstallation':True#跳过UI2的安装,如果第一次运行程序,不要添加该配置
    }
    boss_caps = desired_caps
    #当驱动为ui1,输入中文需要指定输入法
    boss_caps['unicodeKeyboard']=True#修改手机的输入法,UI2不需要设置
    boss_caps['resetKeyboard']=True
    
    
    #初始化driver对象-用于控制手机-启动被测应用
    #IP-appium-server所在机器的网络ip,port-监听的端口号,path固定/wd/hub
    driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)
    driver.implicitly_wait(10)#稳定元素
    #//*[@text="IPC测试工程师"]
    #[40,622]
    size = driver.get_window_size()
    print("size:",size['height'])
    pos_x = size['width']/2
    pos_y = size['height']/4*3
    print("pos_y:",pos_y)
    distance = size['height']/8
    print("distance:",distance)
    while 1:
    
        target =driver.find_elements_by_xpath('//*[@text="IPC测试工程师"]')
        if target:
            print("找到了目标元素")
            break
        driver.swipe(pos_x,pos_y,pos_x,pos_y-distance)
        print(pos_y-distance)
    
    driver.implicitly_wait(10)
    driver.quit()
    
  • 相关阅读:
    Promise 解决回调地狱问题
    同步 异步 API 区别
    静态资源 读取方法
    路由
    HTTP 协议 get post 请求方式
    linux 查看日志
    putty完全使用手册--多窗口---git提交---连接数据库--自动日志显示
    strpos 返回0时 ,比较false 不能加单引号
    禁止使用test类的就是禁止使用本来的$this对象.可以调用父类的对象
    大D实例化model-->调用自定义类方法,大M调用原声model方法
  • 原文地址:https://www.cnblogs.com/venvive/p/13383002.html
Copyright © 2011-2022 走看看