一个流行语言,一个主流工具,一个实用框架:
For android 实例如下:
1 import unittest 2 from appium import webdriver 3 from time import sleep 4 5 class TestSettings(unittest.TestCase): 6 def setUp(self): 7 print("==== Test start ====") 8 caps = {} 9 caps["platformName"] = "Android" 10 caps["platformVersion"] = "8.0.0" 11 caps["deviceName"] = "Phone" 12 caps["appPackage"] = "com.android.settings" 13 caps["appActivity"] = ".Settings" 14 15 self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps) 16 17 def tearDown(self): 18 print("==== Test end ==== ") 19 20 def testWifi(self): 21 self.driver.find_element_by_xpath("//android.widget.TextView[@text='Network & Internet']").click() 22 sleep (3) 23 self.driver.find_element_by_xpath("//android.widget.TextView[@text='Wi-Fi']").click() 24 sleep (2) 25 self.driver.find_element_by_class_name("android.widget.Switch").click() 26 sleep(5) 27 self.driver.find_element_by_accessibility_id("Navigate up").click() 28 sleep (3) 29 self.driver.quit() 30 31 if __name__ == '__main__': 32 unittest.main()