from appium import webdriver
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
import HTMLTestRunner
import unittest
class TestAppSettings(unittest.TestCase):
# 初始化
def setUp(self):
# server 启动参数
desired_caps = {
}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.1'
desired_caps['deviceName'] = 'emulator-5558'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
sleep(2)
# 用例1
# 点击WLAN - --修改网络 - -手动代理 - --自行输入值
def test_WLAN(self):
self.driver.find_element_by_xpath("//*[(@text='WLAN')]").click()
# TouchAction(self.driver).long_press(x=300, y=504).perform()
el = self.driver.find_element_by_id("android:id/title")
TouchAction(self.driver).long_press(el, duration=5000).release().perform()
self.driver.find_element_by_xpath("//*[(@text='修改网络')]").click()
sleep(2)
self.driver.find_element_by_class_name("android.widget.CheckBox").click()
self.driver.find_element_by_id("com.android.settings:id/proxy_settings").click()
sleep(2<
python+appium+unittest+HTMLTestRunner——APP端自动化测试
最新推荐文章于 2024-05-28 20:31:43 发布
本文详细介绍了如何使用Python的unittest模块配合Appium进行APP自动化测试,并利用HTMLTestRunner生成详细的测试报告,包括环境配置、测试用例编写、执行与结果展示等关键步骤。
摘要由CSDN通过智能技术生成