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

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. JQuery:cookie插件

    JQuery居然没有操作cookie相关的函数,搜了下官方有个cookie的插件. 简单使用方法: <head> <title>JQuery-Cookie插件</titl ...

  2. 行列式(determinant)的物理意义及性质

    1. 物理(几何)意义 detA=output areainput area 首选,矩阵代表的是线性变换(linear transformation).上式说明一个矩阵的行列式(detA)几何意义上, ...

  3. erlang---启动参数学习/研究

    erlang启动参数有3种:emulator flags, flags 和plain arguments. emulator flags 是以“+”开头的,用来控制模拟器的行为,附送一个非常实用的例子 ...

  4. python 爬取bilibili 视频弹幕

    # -*- coding: utf-8 -*- # @author: Tele # @Time : 2019/04/09 下午 4:50 # 爬取弹幕 import requests import j ...

  5. 推荐一款软件mybatis-generator-gui

    https://github.com/zouzg/mybatis-generator-gui mybatis-generator-gui mybatis-generator-gui是基于mybatis ...

  6. XSS攻击之基础篇:HTML标签与字符串的渲染

    <body> XSS攻击之基础篇:HTML标签与字符串的渲染 测试 <div class="a1"> </div> <div class= ...

  7. Android 对.properties文件的读取

    /** * * @param filepath .properties文件的位置 */ public void checkFileExists(String filepath){ File file ...

  8. No USB devices or running emulators detected”

    每次重装系统之后,安装andorid studio后,使用真机调试代码,就会出现"No USB devices or running emulators detected"的错误, ...

  9. Eclipse使用技巧总结(四)——代码重构专题

    二十四.重命名 这样重命名就方便多了,不需要一个一个去改了 二十五.移动类和方法 二十六.改变方法 二十七.转换匿名内部类到外部 二十八.提取接口 二十九.抽取成单独方法: Refactor--> ...

  10. 世界卫生组织(WHO)发出最新警告:埃博拉疫情应急响应

    10月14r日.世界卫生组织(WHO)发出警告:在未来两个月内,西非国家将面对"could face up to 10 thousand new Ebola cases a week wit ...