from appium import webdriver
import unittest
from time import sleep
import HTMLTestRunner
from appium.webdriver.common.touch_action import TouchAction
#移动端的设备编号
#adb shell dumpsys window | findstr mCurrentFocus
#app的包名
#app的当前页面【activity】
获取得到的是当前的运行app包名和启动activity
server 启动参数
class TestApp(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1.11'
desired_caps['deviceName'] = 'emulator-5554'
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)
#wifi
def test_Wifi(self):
driver=self.driver
driver.find_element_by_xpath("//*[(@text='WLAN')]").click()
sleep(2)
TouchAction(driver).press(x=460, y=530).wait(3000).release().perform()
driver.find_element_by_xpath("//*[(@text='修改网络')]").click()
driver.find_element_by_xpath("//*[(@text='高级选项')]").click()
driver.find_element_by_xpath("//*[(@text='无')]").click()
sleep(2)
driver.find_element_by_xpath("//*[(@text='手动')]").click()
sleep(2)
driver.find_element_by_xpath("