zoukankan      html  css  js  c++  java
  • 模拟手机操作

    from appium import webdriver
    import os
    import time
    import base64
    
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '7.1'
    desired_caps['devicesName'] = '192.168.50.101:5555'
    desired_caps['appPackage'] = 'com.android.settings'
    desired_caps['appActivity'] = '.Settings'
    
    #声明driver对象
    driver = webdriver.Remote('http:127.0.0.1:21503/wd/hub', desired_caps)
    
    #1.手指轻敲操作
    more = driver.find_element_by_xpath("//*[contains(@text, '更多')]").click()
    TouchAction(driver).tap(more, more.location['x'], more.location['y']).perform()
    time.sleep(3)
    #2.手指按下操作
    battery = driver.find_element_by_xpath("//*[contains(@text, '电池')]").click()
    TouchAction(driver).press(battery, battery.location['x'], battery.location['y']).perform()
    time.sleep(3)
    
    #3.等待操作
    wlan = driver.find_element_by_xpath("//*[contains(@text, 'WLAN')]").click()
    id = driver.find_element_by_xpath("//*[contains(@text, 'ddgqge8585')]")
    TouchAction(driver).press(id, id.location['x'], id.location['y']).wait(3000).release().perform()
    
    #4.手指长按操作
    wlan = driver.find_element_by_xpath("//*[contains(@text, 'WLAN')]").click()
    id = driver.find_element_by_xpath("//*[contains(@text, 'ddgqge8585')]")
    TouchAction(driver).long_press(id, id.location['x'], id.location['y'], 3000).release().perform()
    
    #5.手指移动操作
    wlan = driver.find_element_by_xpath("//*[contains(@text, 'WLAN')]").location
    safe = driver.find_element_by_xpath("//*[contains(@text, '安全')]").location 
    driver.swipe(safe['x'], safe['y'], wlan['x'], wlan['y'])
    date_btn = driver.find_element_by_xpath("//*[contains(@text, '日期和时间')]")
    #必须要release,否则会报错
    TouchAction(driver).long_press(date_btn).move_to(date_btn).release().perform()
    
    driver.close_app()
    driver.quit()
    
  • 相关阅读:
    拷贝构造,移动构造,右值引用,左值,右值,std::move,std::forward,std::ref
    枚举类型 enum以及enum class
    C++ 静态库LIB的使用方法
    array(数组容器)
    C++标准模板库STL
    C++ 动态库DLL的使用方法
    函数指针与回调函数
    VS项目属性等一系列问题
    逻辑运算符(且或非),位运算符(异或),函数对象运算(bit_or)
    pinpoint-grpc编译异常问题记录
  • 原文地址:https://www.cnblogs.com/gerenboke/p/13600813.html
Copyright © 2011-2022 走看看