日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

appium自动化测试(4)部分方法&unitest初步使用

發布時間:2023/10/11 编程问答 71 如意码农
生活随笔 收集整理的這篇文章主要介紹了 appium自动化测试(4)部分方法&unitest初步使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

捕捉彈窗 https://github.com/appium/appium/issues/968完整有截屏的例子:https://github.com/bitbar/testdroid-samples/blob/master/appium/sample-scripts/python/testdroid_android_hybrid.py有詳細解釋的例子:http://www.cnblogs.com/fnng/p/3300788.html

1、unittest
2、截屏并保存driver.save_screenshot("F:/testSpace/unittest0/1.png")

2、setUpClass方法實現,一次性設置3、中文編碼:文件頭添加 #coding:utf-8

完整登陸&退出用例:
  1. #coding:utf-8
  2. ## XX_login_logout_testcase
  3. import unittest
  4. import time
  5. from appium import webdriver
  6.  
  7. classLoginTestCase(unittest.TestCase):
  8. @classmethod
  9. def setUpClass(cls):
  10. print("------------------setUp Test-----------------------")
  11. desired_caps ={}
  12. desired_caps['platformName']='Android'
  13. desired_caps['platformVersion']='4.4.4'
  14. desired_caps['deviceName']='Android Emulator'
  15. desired_caps['appPackage']='com.XX.activity'
  16. desired_caps['appActivity']='.AppStartActivity'
  17. desired_caps['unicodeKeyboard']=True
  18. desired_caps['resetKeyboard']=True
  19. cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
  20. @classmethod
  21. def tearDownClass(cls):
  22. cls.driver.close_app()
  23. cls.driver.quit()
  24. print("-------------------- Byebye ----------------------- ")
  25. def setUp(self):
  26. print("setup")
  27. def tearDown(self):
  28. print("teardown")
  29. def test1_log_in(self):
  30. time.sleep(5)
  31. # wait for the log advertise
  32. self.driver.find_element_by_name(u"我的").click()
  33. self.driver.find_element_by_id('com.XX.activity:id/tv_userheadloginfail_login').click()# 點擊登陸
  34. # log by phone number and password
  35. self.driver.find_element_by_id('com.XX.activity:id/mobile_login').click()
  36. self.driver.find_element_by_id('android:id/text1').click()
  37. self.driver.find_element_by_id('com.XX.activity:id/edt_mobilenum').send_keys("13580478329")
  38. self.driver.find_element_by_id('com.XX.activity:id/edt_password').send_keys("1234567")
  39. self.driver.find_element_by_id('com.XX.activity:id/login').click()
  40. time.sleep(5)
  41. self.driver.save_screenshot("F:/testSpace/loginTestCase1/src/loginByPhoneNumber.png")
  42. print("login ok")
  43. def test2_log_out(self):
  44. # log out
  45. self.driver.find_element_by_name(u"我的").click()
  46. self.driver.find_element_by_id('com.XX.activity:id/rl_usercontent_setting').click()
  47. self.driver.find_element_by_id('com.XX.activity:id/exit').click()
  48. time.sleep(2)
  49. self.driver.find_element_by_id('android:id/button2').click()
  50. time.sleep(5)
  51. self.driver.save_screenshot("F:/testSpace/loginTestCase1/src/logout.png")
  52. print("log out ok")
  53. print("Test2 ok")
  54. if __name__ =='__name__':
  55. unittest.main()
 
 
來自為知筆記(Wiz)

附件列表

總結

以上是生活随笔為你收集整理的appium自动化测试(4)部分方法&unitest初步使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。