①添加读取键盘输入功能,方便测试者选择压测次数!

Python提供了 input() 内置函数从标准输入读入一行文本,默认的标准输入是键盘。

input 可以接收一个Python表达式作为输入,并将运算结果返回。

例:

#!/usr/bin/python3
str = input("请输入:");
print ("你输入的内容是: ", str)

这会产生如下对应的结果:

请输入:ABCD
你输入的内容是: ABCD
#!/usr/bin/python
# -*- coding: UTF-8 -*- '''
==============================================================================================
Usage:
This script performs task that pressure test for automatic restart of equipment. python RebootTest.py
Examples:
python RebootTest.py
==============================================================================================
''' import os
import time rebootCount = int(input("请输入重启次数:"));
print ("你输入的次数是: ", rebootCount) def find_device():
# os.system('adb kill-server')
# os.system('adb start-server')
# os.system('adb root')
# os.system('adb remount')
print("adb devices")
os.system('adb devices') def reboot():
os.system('adb reboot') def screen_downup():
os.system('adb shell input keyevent 26') def power_downup():
os.system('adb shell sendevent /dev/input/event0 1 116 1')
os.system('adb shell sendevent /dev/input/event0 0 0 0')
os.system('adb shell sendevent /dev/input/event0 1 116 0')
os.system('adb shell sendevent /dev/input/event0 0 0 0') def get_log(name,count):
os.system('adb logcat -t 50000 > '+name+count+'.log') #重启
for i in range(0,rebootCount):
find_device
screen_downup()
print("screen_down")
time.sleep(5)
screen_downup()
print("screen_up")
time.sleep(5)
print("power_down")
power_downup()
time.sleep(5)
print("power_up")
power_downup()
count=str(i)
get_log(name="reboot",count=count)
print("auto_reboot loop again")
reboot()
print("wait auto_reboot 60s")
time.sleep(60)
print("auto_reboot finish\n")

【Python】设备重启测试的更多相关文章

  1. Appium+python自动化(三十六)- 士兵突击许三多 - 多个appium服务启动,多个设备启动,多进程并发启动设备-并发测试 - 上(超详解)

    简介 前面课程只是启动了单个appium服务,只能控制单台设备.如果需要针对多台设备测试那么该如何处理?而且发现群里的小伙伴们也在时不时地在讨论这个问题,想知道怎么实现的,于是宏哥就决定写一片这样的文 ...

  2. Python:渗透测试开源项目

    Python:渗透测试开源项目[源码值得精读] sql注入工具:sqlmap DNS安全监测:DNSRecon 暴力破解测试工具:patator XSS漏洞利用工具:XSSer Web服务器压力测试工 ...

  3. selenium + python 多浏览器测试

    selenium + python 多浏览器测试 支持库包 在学习 Python + Selenium 正篇之前,先来看下对多浏览器模拟的支持.目前selenium包中已包含webdriver,hel ...

  4. python 实现九型人格测试小程序

    用python实现九型人格测试,并把测试结果绘制成饼图,实现代码如下: # @Description: 九型人格 import xlrd, matplotlib.pyplot as plt data ...

  5. Appium使用Python运行appium测试的实例

    Appium使用Python运行appium测试的实例 一.  Appium之介绍 https://testerhome.com/topics/8038 详情参考--https://testerhom ...

  6. 基于Python的XSS测试工具XSStrike使用方法

    基于Python的XSS测试工具XSStrike使用方法 简介 XSStrike 是一款用于探测并利用XSS漏洞的脚本 XSStrike目前所提供的产品特性: 对参数进行模糊测试之后构建合适的payl ...

  7. python 程序小测试

    python 程序小测试 对之前写的程序做简单的小测试 ... # -*- encoding:utf-8 -*- ''' 对所写程序做简单的测试 @author: bpf ''' def GameOv ...

  8. 关于测试驱动的开发模式以及实战部分,建议看《Python Web开发测试驱动方法》这本书

    关于测试驱动的开发模式以及实战部分,建议看<Python Web开发测试驱动方法>这本书

  9. Selenium 4 Python的最佳测试框架

    随着Python语言的使用越来越流行,基于Python的测试自动化框架也越来越流行.在项目选择最佳框架时,开发人员和测试人员会有些无法下手.做出选择是应该判断很多事情,框架的脚本质量,测试用例的简单性 ...

随机推荐

  1. 【19.46%】【codeforces 551B】ZgukistringZ

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. IDEA使用从Eclipse过来的快捷键

    1.Eclipse中的ctrl+shift+o --------> Ctrl + Alt + O 2.Eclipse中快捷键是Ctrl+O ---------> MacOS 下是 cmd+ ...

  3. Xcode经常使用插件使用及自己主动生成帮助文档

    *一.Xcode 插件下载:* VVDocumenter下载:https://github.com/onevcat/VVDocumenter-Xcode Xcode经常使用插件下载:http://pa ...

  4. MySQL 备份错误日志

    MySQL 备份错误日志:   shell> mv host_name.err host_name.err-old shell> mysqladmin -u root -p flush-l ...

  5. [React] Use Jest's Snapshot Testing Feature

    Often when testing, you use the actual result to create your assertion and have to manually update i ...

  6. 安装 Visual Studio,连接中国区 Azure

    中国数据中心 目前,中国区 Azure 有两个数据中心,在位置字段中显示为“中国北部”和“中国东部”. 在 Azure 上创建应用程序的区别 在中国区 Azure 上开发应用程序与在境外 Azure ...

  7. 【hdu 2897】邂逅明下

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s) ...

  8. zookeeper 客户端操作

    代码 /** * 创建zk客户端 * 实现循环监听的两个必要条件:1.程序不能结束2.递归调用监听器 * @author tele * */ public class Demo { ; //多个节点用 ...

  9. Dictionary实现(收藏的)

    源文献:https://www.cnblogs.com/InCerry/p/10325290.html 对于C#中的Dictionary类相信大家都不陌生,这是一个Collection(集合)类型,可 ...

  10. 使用JScript脚本批量修改VC工程设置

    作者:朱金灿 来源:http://blog.csdn.net/clever101 很多时候升级了第三方库,需要对很多工程修改设置.在VS中按住Ctrl键确实可以多选工程,但通过这样做也有麻烦的地方:一 ...