zoukankan      html  css  js  c++  java
  • Python操作APP -- Appium-Python-Client

    Appium连接模拟器


    pip install Appium-Python-Client


    使用Appium定位或者使用辅助定位工具

    SDK安装目录/tools/bin,双击此辅助定位工具





    from appium import webdriver
    
    # 配置信息
    desired = {
        "platformName": "Android",
        "platformVersion": "5.1.1",
        "deviceName": "127.0.0.1:62026",
        "appPackage": "com.android.settings",
        "appActivity": ".Settings"
    }
    
    # 固定路径
    driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired)
    
    # 获取屏幕宽高
    width, height = driver.get_window_size().values()
    
    # 滚屏    耗时800ms
    driver.swipe(width * 0.5, height * 0.8, width * 0.5, height * 0.3, 800)
    
    # 定位元素
    # ID
    # element = driver.find_element_by_id('com.android.settings:id/title')
    # xpath
    ele_xpath = '/hierarchy/android.widget.FrameLayout/android.view.View/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.view.View/android.widget.FrameLayout[5]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView'
    element = driver.find_element_by_xpath(ele_xpath)
    
    # 获取内容
    print(element.get_attribute('text'))
    
    # 点击
    element.click()
    




  • 相关阅读:
    编程为谁?
    Nokia S60编程环境的建立(转自彩酷玩家)
    你可以是一个机器吗?
    无法在web服务器上启动调试的解决
    VB.NET和VB6.0有什么区别(转)
    短信3
    短信2
    短信(转自天极)
    短信4
    函数递归调用
  • 原文地址:https://www.cnblogs.com/jiyu-hlzy/p/12228938.html
Copyright © 2011-2022 走看看