• appium常用参数(一)


    from appium import webdriver
    
    desired_caps = {}
    # 系统
    desired_caps['platformName'] = 'Android'
    # 版本
    desired_caps['platformVersion'] = '6.0'
    # 设备号
    desired_caps['deviceName'] = 'LE67A06300301948'
    # 包名
    desired_caps['appPackage'] = 'com.android.settings'
    # 启动名
    desired_caps['appActivity'] = '.Settings'
    # 声明手机驱动对象
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    
    # 关闭APP
    driver.close_app()
    
    # 启动其他APP
    driver.start_activity('com.android.dialer', '.DialtactsActivity')# 安装APP
    driver.install_app('C:\Users\Administrator\Desktop\Phone.2.8.7.apk')
    
    #卸载APP
    driver.remove_app('包名')
    
    # 判断是否安装了APP
    if driver.is_app_installed("包名"):
        driver.remove_app("启动名")
    else:
        driver.install_app("C:\Users\Administrator\Desktop\Phone.2.5.8.apk")
    
    # 发送文件到手机
    import base64
    data = "push 123456push 123456push 123456push 123456push 123456"
    data = str(base64.b64encode(data.encode("utf-8")), "utf-8")
    driver.push_file("/sdcard/a.txt", data)
    
    # 从手机上取文件
    import base64
    data = driver.pull_file("/sdcard/a.txt")
    print(str(base64.b64decode(data), "utf-8"))
    
    
    # 获取页面元素
    data = driver.page_source
    for i in ("蓝牙", "WLAN", "账户"):
        if i in data:
            print(True)
        else:
            print(False)
            
    # 退出手机驱动对象
    driver.quit()
  • 相关阅读:
    java 面向对象(二十二):关键字:final
    The Loss of Bounding Box Regression
    五大经典算法
    二叉树的深度优先遍历(前序、中序、后序)
    faster R-CNN中anchors 的生成过程
    快速排序
    __init__()
    好博客
    Focal Loss for Dense Object Detection(RetinaNet)(代码解析)
    Python获取 当前目录、上一级目录
  • 原文地址:https://www.cnblogs.com/zhaoquanmo/p/10711612.html
Copyright © 2020-2023  润新知