A simple and complete use case for Appium+python

Source: Internet
Author: User
Tags appium

Recently has been busy, finally have the time to tidy up, pass a simple use case, after running can see the use case report, hope to everyone helpful.
Htmltestrunner This package has a lot of online, you can download it yourself.

1 ImportUnitTest2 fromAppiumImportWebdriver3 fromTimeImportSleep4 ImportOS5 ImportTempfile6 fromPILImportImage7 ImportHtmltestrunner8 Import Time9 Ten classlittertestscase (unittest. TestCase): One defsetUp (self): Adesired_cups={} -desired_cups['PlatformName']='Android' -desired_cups['platformversion']='4.4.2' thedesired_cups['devicename']='du2sse15a9032675' -desired_cups['Apppackage']='COM.CLEANMASTER.MGUARD_CN' -desired_cups['appactivity']='com.keniu.security.main.MainActivity' -Self.dr=webdriver. Remote ('Http://localhost:4725/wd/hub', desired_cups) +Sleep (20) - #self.dr.find_element_by_id (' Com.cleanmaster.mguard_cn:id/im '). Click () + #Sleep (5) A defTearDown (self): at self.dr.quit () - #Garbage Cleanup - defClean_litter (self): -CL=SELF.DR.FIND_ELEMENT_BY_ID ('COM.CLEANMASTER.MGUARD_CN:ID/BIW') - Self.assertisnotnone (CL) - Cl.click () inSleep (15) - #If you need to clean up the direct cleanup, do not need to click back---garbage cleanup to Try: +SELF.DR.FIND_ELEMENT_BY_ID ('Com.cleanmaster.mguard_cn:id/af6'). Click () - exceptException as E: the Print(Exception,":"E'Trash Cleanup button') *Self.dr.find_element_name ('Master's Purse'). Click () $ Else:Panax NotoginsengSleep (15) -Self.dr.find_element_by_name ('Master's Purse'). Click () the if __name__=='__main__': +Suite =UnitTest. TestSuite () ASuite.addtest (Littertestscase ('Clean_litter')) the #UnitTest. Texttestrunner (verbosity=2). Run (Suite) -
Filename='c:\\test-zq\\report\\report.html' $Fp=open (filename,'WB') $Runner=Htmltestrunner.htmltestrunner ( -stream=FP, -Title=u'result', theDescription=u' Report' - )Wuyi Runner.run (Suite) theFp.close ()

A simple and complete use case for Appium+python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.