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()
    
  • 相关阅读:
    flutter 刷新和初始化
    flutter 复杂数据模型 转换
    flutter 刷新组件
    flutter wrap 流式布局
    添加横纵布局 和 页面保活
    跳转首页结构并且加载launch插件
    迟到的AFO
    [ELSE]自闭选手的自我修养
    [题解]UOJ#41 矩阵变换
    [题解]HDU 3555 Bomb
  • 原文地址:https://www.cnblogs.com/venvive/p/13383002.html
Copyright © 2011-2022 走看看