Appium+python的一個簡單完整的用例

來源:互聯網
上載者:User

標籤:file   cli   ima   time   remote   ext   4.4   清理   ast   

最近一直在忙,終於有時間來整理一下,傳一個簡單的用例,運行之後可以看到用例的報告,希望對大家有協助。
HTMLTestRunner這個包網上有很多,大家可以自己下載。

1
import unittest 2 from appium import webdriver 3 from time import sleep 4 import os 5 import tempfile 6 from PIL import Image 7 import HTMLTestRunner 8 import time 9 10 class LitterTestscase(unittest.TestCase):11 def setUp(self):12 desired_cups={}13 desired_cups[‘platformName‘]=‘Android‘14 desired_cups[‘platformVersion‘]=‘4.4.2‘15 desired_cups[‘deviceName‘]=‘DU2SSE15A9032675‘16 desired_cups[‘appPackage‘]=‘com.cleanmaster.mguard_cn‘17 desired_cups[‘appActivity‘]=‘com.keniu.security.main.MainActivity‘18 self.dr=webdriver.Remote(‘http://localhost:4725/wd/hub‘,desired_cups)19 sleep(20)20 # self.dr.find_element_by_id(‘com.cleanmaster.mguard_cn:id/im‘).click()21 # sleep(5)22 def tearDown(self):23 self.dr.quit()24 #垃圾清理25 def clean_litter(self):26 cl=self.dr.find_element_by_id(‘com.cleanmaster.mguard_cn:id/biw‘)27 self.assertIsNotNone(cl)28 cl.click()29 sleep(15)30 #如果需要清理直接清理,不需要則點擊返回---垃圾清理31 try:32 self.dr.find_element_by_id(‘com.cleanmaster.mguard_cn:id/af6‘).click()33 except Exception as e:34 print(Exception, ":", e, ‘垃圾清理按鈕‘)35 self.dr.find_element_name(‘大師錦囊‘).click()36 else:37 sleep(15)38 self.dr.find_element_by_name(‘大師錦囊‘).click()39 if __name__==‘__main__‘:40 suite = unittest.TestSuite()41 suite.addTest(LitterTestscase(‘clean_litter‘))42 #unittest.TextTestRunner(verbosity=2).run(suite)44
    filename=‘C:\\Test-ZQ\\report\\report.html‘45 fp=open(filename,‘wb‘)46 runner=HTMLTestRunner.HTMLTestRunner(47 stream=fp,48 title=u‘result‘,49 description=u‘report‘50 )51 runner.run(suite)52 fp.close()

 

Appium+python的一個簡單完整的用例

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.