一、环境
1、安装python。
2、安装appium。
3、安装pip
4、安装selenium
5、安装Appium-Python-Client #cmd->cd setuptools\pip install Appium-Python-Client
二、Appium配置
启动Appium后,点击安卓机器人
三、编写脚本
1 # -*- coding:utf-8 -*- 2 3 4 import unittest 5 import os 6 import sys 7 from time import sleep 8 from appium import webdriver 9 10 class HelloWorld(unittest.TestCase): 11 def test_ssq(self): 12 desired_caps = {} 13 desired_caps[‘platformName‘] = ‘Android‘ 14 desired_caps[‘platformVersion‘] = ‘4.4.4‘ 15 desired_caps[‘appPackage‘] = ‘com.golive.lottery‘ 16 desired_caps[‘appActivity‘] = ‘.activity.HomeActivity‘ 17 desired_caps[‘deviceName‘] = ‘172.17.2.69:5555‘ 18 19 driver = webdriver.Remote(‘http://127.0.0.1:4723/wd/hub‘, desired_caps) 20 21 time.sleep(5) 22 23 ssq = driver.find_element_by_id(‘com.golive.lottery:id/lottery_ssq‘).click() 24 25 26 if __name__ == ‘__main__‘: 27 suite = unittest.TestLoader().loadTestsFromTestCase(HelloWorld) 28 unittest.TextTestRunner(verbosity=2).run(suite) 29
时间: 2024-10-20 19:21:45