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

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. pycharm Zooming in the Editor

    https://www.jetbrains.com/help/pycharm/zooming-in-the-editor.html To enable changing font size in th ...

  2. 手把手教你完成App支付JAVA后台-支付宝支付JAVA

    接着上一篇博客,我们暂时完成了手机端的部分支付代码,接下来,我们继续写后台的代码. 后台基本需要到以下几个参数,我都将他们写在了properties文件中: 支付宝参数 AliPay.payURL = ...

  3. [Typescript] Sorting arrays in TypeScript

    In this lesson we cover all the details of how to sort a list of items using TypeScript. We also pre ...

  4. 非常实用全面的 C++框架,库类等资源

    这次的资源涉及到了标准库.Web应用框架.人工智能.数据库.图片处理.机器学习.日志.代码分析等,C++程序员学习必备! Jason frozen : C/C++的Jason解析生成器 Jansson ...

  5. 《图说VR》——HTC Vive控制器按键事件解耦使用

    本文章由cartzhang编写,转载请注明出处. 全部权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/53915229 作者:car ...

  6. [redis] redis配置文件redis.conf的详细说明

    # Redis 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, 5GB, 4M 等类似的格式,其转换方式如下(不区分大小写) # # 1k => bytes # 1kb => ...

  7. python 多进程与多线程配合拷贝文件目录

    版本一:使用shutil进行拷贝 # -*- coding: utf-8 -*- # @author: Tele # @Time : 2019/04/02 下午 3:09 # 待改进: # 1.拷贝逻 ...

  8. qt-4.8.4安装和环境变量配置

    在Linux中分别安装应用于不同平台的Qt:PC.嵌入式X86:ARM. 这三者PC版.嵌入式X86版和ARM版的差别主要体如今:当configure时分别加了不同的參数,详细差别是: PC平台(X1 ...

  9. 通过getElementById来取得Form里的表单元素

    <1> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>湖南易通 ...

  10. bootstrap, boosting, bagging

    介绍boosting算法的资源: 视频讲义.介绍boosting算法,主要介绍AdaBoosing http://videolectures.net/mlss05us_schapire_b/ 在这个站 ...