① 目的
将启动APP方法封装,便于多次调用
② 环境
Python+Appium+Android/IOS模拟器
③源码
from appium import webdriver
import unittest
from selenium.common.exceptions import NoSuchElementException
class desired(unittest.TestCase):
def setUp(self):
pass
# 终端执行命令,连接本地端口
def MAC_terminal(self, comand):
# 打开一个终端
os.system("open -a Terminal .")
# 执行命令
comand = comand
appscript.app('Terminal').do_script(comand)
# 启动android模拟器
def test_Android_Lekechat(self):
Driver_IOS_Lekechat.MAC_terminal(self, 'adb connect localhost:62001')
self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities={'platformName': 'Android', # 设备型号
'platformVersion': '7.1.2', # 系统版本
'deviceName': 'localhost:62001', # 端口号默认62001
# 安装包路径;r覆盖安装
'app': '/Users/yangwei/Desktop/test.apk',
# 安装包名称,通过uiautomatorviewer工具获取。或者使用:aapt dump badging /Users/yangwei/Desktop/test.apk
'appPackage': 'com.leke.lekechat'
})
})
def tearDown(self):
print('测试完毕!')
self.driver.quit()
白嫖不好,创作不易,各位的点赞就是创作的最大动力。 持续更新,未完待续……