main.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. sleep(1)
  16. # 点击考勤
  17. touch(Template('./img/checking_white.png'))
  18. sleep(1)
  19. def main():
  20. try:
  21. # 连接手机->自动启动wda
  22. wda = init_device("IOS",UDID)
  23. try:
  24. # 打开d钉钉
  25. wda.start_app(DD_BUNDLE_ID)
  26. sleep(1)
  27. onDuty()
  28. sleep(1)
  29. wda.snapshot('test5.png')
  30. except Exception as es:
  31. print('操作错误',es)
  32. except EnvironmentError as e:
  33. print('连接错误',e)
  34. if __name__ == '__main__':
  35. main()