zoukankan      html  css  js  c++  java
  • app ui 自动化,知识碎片


    获取APP页面源码并写入一个XML文件
      page_source=driver.page_source
      with open("data.xml","w") as f:
        f.writelines(page_source)

    将UTC时间转换为指定格式时间 localtime()
      timeStruct = time.localtime(os.path.getmtime(oldname))
      print timeStruct
      print time.strftime('%Y-%m-%d %H:%M:%S',timeStruct)
    输出python日志
      stdout_backup = sys.stdout
      log_file = open("message.log", "w")
      sys.stdout = log_file
      print u'输出这一段的print内容到message.log里'
      print u'这里就是日志的内容!'
      log_file.close()
      sys.stdout = stdout_backup

    开关WiFi 和 移动数据网络

      ***参数需要修改
      Turn on wifi - adb shell am start -n io.appium.settings/.Settings -e wifi on
      Turn off WiFi - adb shell am start -n io.appium.settings/.Settings -e wifi off
      Turn on mobile data - adb shell am start -n io.appium.settings/.Settings -e data on
      Turn off mobile data - adb shell am start -n io.appium.settings/.Settings -e data off

    adb命令手机屏幕截图

      os.popen('adb -s %s shell am start -n io.appium.settings/.Settings -e wifi off'%self.conName)
      os.popen('adb -s %s shell screencap -p /sdcard/app_%s.png'%(self.conname,time))
      path=task_path+'\app_%s.png'%time
      os.popen("adb -s %s pull /sdcard/app_%s.png %s"%(self.conname,time,path))
      os.popen('adb -s %s shell rm /sdcard/app_%s.png'%(self.conname,time))
      // 广播,告知其他应用有图片更新

      os.popen('adb -s %s shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/app_%s.png'%(self.conname,time))

    NULL ...

  • 相关阅读:
    JQuery Ajax 在asp.net中使用小结
    加班对你的提升有多大?
    .net学习笔记---HttpResponse类
    .net学习笔记----HttpRequest类
    MVC学习笔记---MVC生命周期
    MVC学习笔记---MVC生命周期及管道
    .net学习笔记---HttpHandle与HttpModule
    C#学习笔记---修饰符,this关键字和static关键字
    C#学习笔记---如何提高代码逼格
    Linq学习笔记---Linq to Sql之where
  • 原文地址:https://www.cnblogs.com/liuyun66535309/p/10321144.html
Copyright © 2011-2022 走看看