1 #-*-ecoding:utf-8-*-2 fromAppiumImportWebdriver3 fromSelenium.webdriver.support.waitImportwebdriverwait4 ImportUnitTest5 fromTimeImportSleep6 Import Time7 ImportHtmltestrunner8 Importio9 Ten classWebcat_open (unittest. TestCase): One defsetUp (self): Adesired_caps={"PlatformName":"Android", - "platformversion":"6.0", - "devicename":"ZTEBV0710", the "Apppackage":"com.tencent.mm", - "appactivity":"Com.tencent.mm.ui.LauncherUI", - "Unicodekeyboard":"true"} -Self.driver=webdriver. Remote ("Http://192.168.2.226:4723/wd/hub", Desired_caps) + defTearDown (self): - self.driver.quit () + A defTest_open (self): atDr=Self.driver -Qh=webdriverwait (dr,10). Until (LambdaDr:dr.find_element_by_name (U"I'm")) - Qh.click () -Dr.find_element_by_name (U"Set"). Click () - Print(Dr.current_context) - Print(dr.current_activity) inSleep (10) - defTest_xy (self): to Pass + defTEST_WC (self): - Pass the *Unitsuits=unittest.defaulttestloader.discover (start_dir=r"C:\Users\syf1225\PycharmProjects\appium", $pattern="web*.py",Panax NotoginsengTop_level_dir=None) -unitsuit=UnitTest. TestSuite () the forSuitsinchunitsuits: + Print(suits) A forSuitinchSuits: the unitsuit.addtests (SUIT) + Print(SUIT) - $ if __name__=="__main__": $now = Time.strftime ("%y%m%d%h%m%s", Time.localtime ()) -filename ="c:\\users\\syf1225\\pycharmprojects\\appium\\htmereport\\"+ now+"result.html" -FILE = open (filename,"WB") theRunner=htmltestrunner.htmltestrunner (stream=file, -Title=u"Test",WuyiVerbosity=1, theDescription=u"python script, Android 6.0,windows10") -Runner.run (Unitsuit)
The above code is used to do some testing, according to this code basically can complete most UI-based testing
Appium Basic Framework