• PythonAppium自动化测试环境搭建


    Python环境

    在CMD中运行 pip install Appium-Python-Client

    Microsoft Windows [版本 10.0.19045.3693]
    (c) Microsoft Corporation。保留所有权利。
    
    C:\Users\Administrator>pip install Appium-Python-Client
    Collecting Appium-Python-Client
      Downloading Appium-Python-Client-3.1.0.tar.gz (3.4 MB)
         ---------------------------------------- 3.4/3.4 MB 297.9 kB/s eta 0:00:00
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Preparing metadata (pyproject.toml) ... done
    Requirement already satisfied: selenium~=4.12 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from Appium-Python-Client) (4.15.2)
    Requirement already satisfied: urllib3<3,>=1.26 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from urllib3[socks]<3,>=1.26->selenium~=4.12->Appium-Python-Client) (2.0.7)
    Requirement already satisfied: trio~=0.17 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from selenium~=4.12->Appium-Python-Client) (0.23.1)
    Requirement already satisfied: trio-websocket~=0.9 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from selenium~=4.12->Appium-Python-Client) (0.11.1)
    Requirement already satisfied: certifi>=2021.10.8 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from selenium~=4.12->Appium-Python-Client) (2023.7.22)
    Requirement already satisfied: attrs>=20.1.0 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (23.1.0)
    Requirement already satisfied: sortedcontainers in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (2.4.0)
    Requirement already satisfied: idna in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (3.4)
    Requirement already satisfied: outcome in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (1.3.0.post0)
    Requirement already satisfied: sniffio>=1.3.0 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (1.3.0)
    Requirement already satisfied: cffi>=1.14 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio~=0.17->selenium~=4.12->Appium-Python-Client) (1.16.0)
    Requirement already satisfied: wsproto>=0.14 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from trio-websocket~=0.9->selenium~=4.12->Appium-Python-Client) (1.2.0)
    Requirement already satisfied: pysocks!=1.5.7,<2.0,>=1.5.6 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from urllib3[socks]<3,>=1.26->selenium~=4.12->Appium-Python-Client) (1.7.1)
    Requirement already satisfied: pycparser in c:\users\administrator\appdata\roaming\python\python312\site-packages (from cffi>=1.14->trio~=0.17->selenium~=4.12->Appium-Python-Client) (2.21)
    Requirement already satisfied: h11<1,>=0.9.0 in c:\users\administrator\appdata\roaming\python\python312\site-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium~=4.12->Appium-Python-Client) (0.14.0)
    Building wheels for collected packages: Appium-Python-Client
      Building wheel for Appium-Python-Client (pyproject.toml) ... done
      Created wheel for Appium-Python-Client: filename=Appium_Python_Client-3.1.0-py3-none-any.whl size=337588 sha256=d29b618102d0b617d4b42076d3b21df506d701b10f3669ae5079861b7261e24a
      Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\f9\96\78\c77d7a11d58afb91cf95104558a38e4e56745a8590177f71da
    Successfully built Appium-Python-Client
    Installing collected packages: Appium-Python-Client
    Successfully installed Appium-Python-Client-3.1.0
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33

    Appium

    示例代码

    '''
    @Time    : 2018/11/12 13:37
    @Author  : davieyang
    @Software: PyCharm
    @Description:
    '''
    # encoding = utf-8
    from appium import webdriver
    import time
    import unittest
     
     
    class test_ClickButon(unittest.TestCase):
    def setUp(self):
            desired_caps = {
    'platformName': 'Android',
                        'deviceName': '30d4e606',
                        'platformVersion': '5.0',
                        'appPackage': 'com.tencent.qqpimsecure',
                        'appActivity': 'com.tencent.server.fore.QuickLoadActivity'
                        }
    self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
     
    def test_ClickButton(self):
            driver = self.driver
            driver.find_element_by_id("com.tencent.mobileqq:id/btn_login").click()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    ​​​​​​​​​​​​​​​​​​​​

  • 相关阅读:
    如何计算Renko大小,FPmarkets用ATR3步计算
    在C#中,如何以编程的方式设置 Excel 单元格样式
    Linux磁盘管理、储存空间
    Python初级练习小实例(1-20例),1个实例多个例子相互参考
    34. 在排序数组中查找元素的第一个和最后一个位置
    PHP旅游管理系统Dreamweaver开发mysql数据库web结构php编程计算机网页
    正式成为研究生一个月就可以改变一个人
    19 视图定义 union 是根据第一个 select 字段列表顺序,来进行 merge 的
    【区块链技术与应用】(五)
    Alpha、Beta、RC、GA、RTW版本
  • 原文地址:https://blog.csdn.net/dawei_yang000000/article/details/134530712