appium+python环境搭建

时间:2022-04-10 02:49:07

一、环境

1、安装python。

2、安装appium。

3、安装pip

4、安装selenium

5、安装Appium-Python-Client       #cmd->cd setuptools\pip install Appium-Python-Client

二、Appium配置

启动Appium后,点击安卓机器人

appium+python环境搭建

三、编写脚本

 # -*- coding:utf-8 -*-

 import unittest
import os
import sys
from time import sleep
from appium import webdriver class HelloWorld(unittest.TestCase):
def test_ssq(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.4'
desired_caps['appPackage'] = 'com.golive.lottery'
desired_caps['appActivity'] = '.activity.HomeActivity'
desired_caps['deviceName'] = '172.17.2.69:5555' driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) time.sleep(5) ssq = driver.find_element_by_id('com.golive.lottery:id/lottery_ssq').click() if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(HelloWorld)
unittest.TextTestRunner(verbosity=2).run(suite)