main.py 966 B

12345678910111213141516171819202122232425262728293031323334353637
  1. from airtest.core.api import init_device,assert_exists,Template,touch
  2. from time import sleep
  3. DD_BUNDLE_ID = 'com.laiwang.DingTalk' # 钉钉包名
  4. WDA_BUNDLE_ID = 'com.caner.test.xctrunner' #个人包名
  5. UDID = '00008030-000415D614E0402E' # pymobiledevice3 usbmux list 查看手机id
  6. def offDuty():
  7. # 下班工作台
  8. touch(Template('./img/gzt_black.png'))
  9. sleep(1)
  10. # 点击考勤
  11. touch(Template('./img/checking_black.png'))
  12. def onDuty():
  13. # 上班工作台
  14. touch(Template('./img/gzt_white.png'))
  15. def main():
  16. try:
  17. # 连接手机->自动启动wda
  18. wda = init_device("IOS",UDID)
  19. try:
  20. # 打开d钉钉
  21. wda.start_app(DD_BUNDLE_ID)
  22. sleep(1)
  23. offDuty()
  24. wda.snapshot('test4.png')
  25. except Exception as es:
  26. print('操作错误',es)
  27. except EnvironmentError as e:
  28. print('连接错误',e)
  29. if __name__ == '__main__':
  30. main()