捕捉弹窗 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()
 
 

附件列表

最新文章

  1. [erl] erlang 进程注册和注销
  2. OD使用教程4
  3. shopex商城的部署和安装
  4. motto4
  5. oracle group by中cube和rollup字句的使用方法及区别
  6. cocos2d-x 扩充引擎基类功能 引起的头文件重复包含问题的分析
  7. zoj3658 Simple Function (函数值域)
  8. Eclipse RCP /Plugin移除Search对话框
  9. 温故知新 javascript 正则表达式
  10. curl: (48) An unknown option was passed in to libcurl怎么解决
  11. MP4文件格式
  12. python-day33--进程间通信(IPC)
  13. tomcat 启动超级慢
  14. KHFlatButton
  15. ot
  16. Loader拉取图片,由于redirect重定向,导致策略文件无效 设置checkPolicyFile后还是无效:需要一个策略文件,但在加载此媒体时未设置 checkPolicyFile 标志
  17. [转]C/C++作用域详解
  18. Linux:LAMP搭建DISCU!论坛
  19. ThinkJS 中的Logic层
  20. sense之间的数据传输

热门文章

  1. Vue(12)组件的组织结构和组件注册
  2. 移动端touch、click、tap的区别
  3. Docker搭建EFK日志收集系统,并自定义es索引名
  4. AcWing 201. 可见的点
  5. idea中IDEA优化配置
  6. buu SimpleRev
  7. Docker基础:VMware虚拟机Centos7环境下docker安装及使用
  8. 按键控制LED灯-ESP32中断处理
  9. STM32中STD、HAL、LL库比较
  10. Linux | Shell脚本的编写