提高测试人员测试效率之GUI工具

2024-03-08 23:59

本文主要是介绍提高测试人员测试效率之GUI工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

如何有效的去提高测试效率,在一个团队当中,肯定会存在部分人员无法熟悉数据库操作的情况,这个时候我们就可以通过GUI编程将工具界面会,使之快速的上手
本次通过一个GUI工具来带领大家如何制作这么个工具
功能实现页面如下图
在这里插入图片描述

以下部分代码未保密,隐藏数据库连接及URL
```python
import sys
import pymysql
import requests
from PyQt5.QtCore import QObject, pyqtSignal, QBasicTimer, Qt
from PyQt5.QtGui import QTextCursor, QFont, QIcon
from gongju import Ui_Form
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtWidgets import *class Signal(QObject):text_update = pyqtSignal(str)def write(self, text):self.text_update.emit(str(text))QApplication.processEvents()class MyClass(QWidget, Ui_Form):def __init__(self):super().__init__()self.InitUi()def InitUi(self):self.setupUi(self)self.setWindowTitle("测试工具")window_pale = QtGui.QPalette()window_pale.setBrush(self.backgroundRole(), QtGui.QBrush(QtGui.QPixmap("D:\Guitest\\background.png")))self.setPalette(window_pale)self.show()self.pushButton_2.clicked.connect(self.chognzhi)self.pushButton.clicked.connect(self.deleteuser)self.pushButton_3.clicked.connect(self.FindUser)self.pushButton_8.clicked.connect(self.denglu)self.pushButton_9.clicked.connect(self.shangban)self.pushButton_10.clicked.connect(self.xiaban)self.pushButton_7.clicked.connect(self.jiandan)self.pushButton_11.clicked.connect(self.yijiaofei)self.pushButton_12.clicked.connect(self.wijiaofei)self.txt = QtWidgets.QTextEdit()# 实时显示输出, 将控制台的输出重定向到界面中sys.stdout = Signal()sys.stdout.text_update.connect(self.updatetext)def updatetext(self, text):"""更新测试结果到textBrowser"""cursor = self.textBrowser.textCursor()cursor.movePosition(QTextCursor.End)self.textBrowser.append(text)self.textBrowser.setTextCursor(cursor)self.textBrowser.ensureCursorVisible()def chognzhi(self):reply = QMessageBox.information(self, "确认", "确认重置?",QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)if reply == QMessageBox.No:print('退出')passelse:if self.comboBox.currentText()=="微信":clientType=0else:clientType=1phone=self.lineEdit_2.text()url = "https:/sysuser/reset/region"payload = {"phone":phone,"clientType":clientType}headers = {'authdst': '683603105505349632','Authorization': 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJvTEdJRndwblhtYXEzZDdYOFFhUEhuQTZQSk93O293SWVWNU5nU1dzWEFBTXdseTVaZUxOSTNQekkiLCJjcmVhdGVkIjoxNjY5NTk4NTcyNjUzLCJleHAiOjE2Njk4NTc3NzJ9.Y7YPMl_rZeKOXajAREC7SWgMh9xH3YV0kPmPJcJEabInl3o-denV-mQwpYrbsgaZR2b59n_X8XjX9rmz7duHzQ','from': '0','linkid': '0','userid': '683603105505349632'}try:response = requests.post(url, headers=headers, json=payload)print('归属地重置进行中...')if response.json()["res"]["codeMsg"]== None:print('归属地重置成功!')elif response.json()["res"]["codeMsg"].strip()== "用戶不存在":#去掉字符串中其他符号print('用户不存在!')else:print('请求异常!')except Exception as e:print(e)def deleteuser(self):  # 连接mysql数据库userphone=self.lineEdit.text()connection = pymysql.connect(host="888.9--.100.194", port=23306, user='root', password="ZKtest@2020",db="web_db")print('数据库连接成功!')reply = QMessageBox.information(self, "确认", "确认删除?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)if reply == QMessageBox.No:print('退出')passelse:print("删除数据进行中...")cursor = connection.cursor()  # 获取游标sql1 = f'DELETE FROM t_user_wechat WHERE  phone="{userphone}"'sql2 = f'DELETE FROM t_user_player WHERE  phone="{userphone}"'sql3 = f'DELETE FROM t_user_alipay WHERE  phone="{userphone}"'sql4 = f'DELETE FROM t_user_platform_union WHERE  phone="{userphone}"'sql5= f'SELECT * FROM t_user_wechat WHERE  phone="{userphone}"'sql6 = f'SELECT * FROM t_user_alipay  WHERE  phone="{userphone}"'try:# 执行SQL语句count1=cursor.execute(sql5)if count1 >= 1:print("查询到%d条微信账号数据" % count1)cursor.execute(sql1)# 提交到数据库执行connection.commit()print("删除微信账号数据成功!")else:print("没有查询到有微信账号!")count3 = cursor.execute(sql6)if count3 >= 1:print("查询到%d条支付宝账号数据" % count3)cursor.execute(sql3)# 提交到数据库执行connection.commit()print("删除支付宝账号数据成功!")else:print("没有查询到有支付宝账号!")cursor.execute(sql2)cursor.execute(sql4)# 提交到数据库执行connection.commit()except Exception as e:print("删除数据失败:case%s" % e)QMessageBox.about(self, '提示', '删除数据失败!')# 发生错误时回滚connection.rollback()finally:# 关闭游标连接cursor.close()# 关闭数据库连接connection.close()def FindUser(self):try:connection = pymysql.connect(host="-6618.98.100.194", port=23306, user='root', password="ZKtest@2020",db="web_db")print('数据库连接成功!')userphone = self.lineEdit_3.text()cursor = connection.cursor(cursor=pymysql.cursors.DictCursor)  # 获取游标sql7 = f'SELECT * FROM  t_user_platform_union  WHERE  phone="{userphone}"'# 执行SQL语句cursor.execute(sql7)subid=cursor.fetchall()[0]["sub_id"]print('查询到userid是:'+f'{subid}')reply = QMessageBox.information(self, "确认", "确认清除?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)if reply == QMessageBox.No:print('退出')passelse:try:print("删除数据进行中...")cursor = connection.cursor()  # 获取游标sql8 = f'DELETE FROM t_coupon_task_finish WHERE  user_id="{subid}"'cursor.execute(sql8)# 提交到数据库执行connection.commit()print("清除新手任务成功!")except Exception as e:print("删除数据失败:case%s" % e)QMessageBox.about(self, '提示', '删除数据失败!')# 发生错误时回滚connection.rollback()finally:# 关闭游标连接cursor.close()# 关闭数据库连接connection.close()except Exception as e:print(e)def denglu(self):username = self.lineEdit_9.text()url = "https:managerlogin/gettoken"payload = {"number": username, "password": "c4ca4238a0b923820dcc509a6f75849b","ime":"868597059438958"}headers = {'Content-Type': 'application/json',}try:response = requests.post(url, headers=headers, json=payload)print('收费员登录中...')if response.json()["res"]["codeMsg"] == None:print('收费员登录成功!')print('请执行上班操作!')self.token=response.json()["res"]["data"]["token"]elif response.json()["res"]["codeMsg"].strip() == "用戶不存在":  # 去掉字符串中其他符号print('用户不存在!')else:print('请求异常!')except Exception as e:print(e)def shangban(self):url = "https:alarm/work/start"payload = {"roleId": 582, "roadId": ["316232857695551498"], "addr": "","latitude": "","longitude": ""}headers = {'authdst': '121609970406916096','linkid':'119761632728449025','userid':'121609970406916096','Content-Type': 'application/json'}try:response = requests.post(url, headers=headers, json=payload)print('收费员上班中...')if response.json()["res"]["codeMsg"] == None:print('收费员上班成功!')print('请执行建单操作!')else:print("上班失败,厦门中卡测试2区已有人上班")except Exception as e:print(e)def xiaban(self):url = "https:alarm/work/end"payload = {"roleId": 582, "roadId": ["316232857695551498"], "addr": "","latitude": "","longitude": ""}headers = {'authdst': '121609970406916096','linkid':'119761632728449025','userid':'121609970406916096','Content-Type': 'application/json'}try:response = requests.post(url, headers=headers, json=payload)print('收费员下班中...')if response.json()["res"]["codeMsg"] == None:print('收费员下班成功!')else:print("请求异常")except Exception as e:print(e)def jiandan(self):url = "https:rosideorder/order/create"startTime=self.dateTimeEdit.text()carno=self.lineEdit_5.text()payload = {"parkId": "11112", "startTime": startTime, "carNo":carno,"enterpriseId": "119761632728449025","createName": "123","newEnergy": 0,"carType": 1}headers = {'authdst': '121609970406916096','linkid':'119761632728449025','userid':'121609970406916096','Content-Type': 'application/json'}try:response = requests.post(url, headers=headers, json=payload)print('创建订单中...')if response.json()["res"]["codeMsg"] == None:print('创建订单成功!')else:print("请求异常")url = 'rosideorder/order/listex'parms01 = {'page': 1,'pageSize':10000,'status':1,'roadId':'316232857695551498','roleId':582}headers = {'authdst': '121609970406916096','linkid': '119761632728449025','userid': '121609970406916096','Content-Type': 'application/json'}ret = requests.get(url, headers=headers, params=parms01)#print(ret.json()["res"]["data"]["result"]["list"])for i in ret.json()["res"]["data"]["result"]["list"]:#print(i)if i["parkId"]== "11112":self.lineEdit_13.setText(i["orderId"])except Exception as e:print(e)def yijiaofei(self):try:url = "https:rosideorder/order/pay"endTime=self.dateTimeEdit_3.text()orderId=self.lineEdit_13.text()payload = {"endTime": endTime, "orderId": orderId, "userName":"123","type": 0}headers = {'authdst': '121609970406916096','linkid':'119761632728449025','userid':'121609970406916096','Content-Type': 'application/json'}response = requests.post(url, headers=headers, json=payload)print('结算订单中...')if response.json()["res"]["codeMsg"] == None:print('结算订单成功!')else:print("请求异常")except Exception as e:print(e)def wijiaofei(self):try:url = "https:rosideorder/order/pay"endTime=self.dateTimeEdit_3.text()orderId=self.lineEdit_13.text()payload = {"endTime": endTime, "orderId": orderId, "userName":"123","type": 1}headers = {'authdst': '121609970406916096','linkid':'119761632728449025','userid':'121609970406916096','Content-Type': 'application/json'}response = requests.post(url, headers=headers, json=payload)print('结算订单中...')if response.json()["res"]["codeMsg"] == None:print('结算订单成功!')else:print("请求异常")except Exception as e:print(e)if __name__ == '__main__':app = QApplication(sys.argv)mc = MyClass()sys.exit(app.exec_())

这篇关于提高测试人员测试效率之GUI工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/788854

相关文章

Python基于wxPython和FFmpeg开发一个视频标签工具

《Python基于wxPython和FFmpeg开发一个视频标签工具》在当今数字媒体时代,视频内容的管理和标记变得越来越重要,无论是研究人员需要对实验视频进行时间点标记,还是个人用户希望对家庭视频进行... 目录引言1. 应用概述2. 技术栈分析2.1 核心库和模块2.2 wxpython作为GUI选择的优

使用Java实现通用树形结构构建工具类

《使用Java实现通用树形结构构建工具类》这篇文章主要为大家详细介绍了如何使用Java实现通用树形结构构建工具类,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录完整代码一、设计思想与核心功能二、核心实现原理1. 数据结构准备阶段2. 循环依赖检测算法3. 树形结构构建4. 搜索子

Python GUI框架中的PyQt详解

《PythonGUI框架中的PyQt详解》PyQt是Python语言中最强大且广泛应用的GUI框架之一,基于Qt库的Python绑定实现,本文将深入解析PyQt的核心模块,并通过代码示例展示其应用场... 目录一、PyQt核心模块概览二、核心模块详解与示例1. QtCore - 核心基础模块2. QtWid

利用Python开发Markdown表格结构转换为Excel工具

《利用Python开发Markdown表格结构转换为Excel工具》在数据管理和文档编写过程中,我们经常使用Markdown来记录表格数据,但它没有Excel使用方便,所以本文将使用Python编写一... 目录1.完整代码2. 项目概述3. 代码解析3.1 依赖库3.2 GUI 设计3.3 解析 Mark

利用Go语言开发文件操作工具轻松处理所有文件

《利用Go语言开发文件操作工具轻松处理所有文件》在后端开发中,文件操作是一个非常常见但又容易出错的场景,本文小编要向大家介绍一个强大的Go语言文件操作工具库,它能帮你轻松处理各种文件操作场景... 目录为什么需要这个工具?核心功能详解1. 文件/目录存javascript在性检查2. 批量创建目录3. 文件

jvm调优常用命令行工具详解

《jvm调优常用命令行工具详解》:本文主要介绍jvm调优常用命令行工具的用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一 jinfo命令查看参数1.1 查看jvm参数二 jstack命令2.1 查看现场堆栈信息三 jstat 实时查看堆内存,gc情况3.1

MySQL使用binlog2sql工具实现在线恢复数据功能

《MySQL使用binlog2sql工具实现在线恢复数据功能》binlog2sql是大众点评开源的一款用于解析MySQLbinlog的工具,根据不同选项,可以得到原始SQL、回滚SQL等,下面我们就来... 目录背景目标步骤准备工作恢复数据结果验证结论背景生产数据库执行 SQL 脚本,一般会经过正规的审批

基于Python开发批量提取Excel图片的小工具

《基于Python开发批量提取Excel图片的小工具》这篇文章主要为大家详细介绍了如何使用Python中的openpyxl库开发一个小工具,可以实现批量提取Excel图片,有需要的小伙伴可以参考一下... 目前有一个需求,就是批量读取当前目录下所有文件夹里的Excel文件,去获取出Excel文件中的图片,并

Java导入、导出excel用法步骤保姆级教程(附封装好的工具类)

《Java导入、导出excel用法步骤保姆级教程(附封装好的工具类)》:本文主要介绍Java导入、导出excel的相关资料,讲解了使用Java和ApachePOI库将数据导出为Excel文件,包括... 目录前言一、引入Apache POI依赖二、用法&步骤2.1 创建Excel的元素2.3 样式和字体2.

基于Python开发PDF转PNG的可视化工具

《基于Python开发PDF转PNG的可视化工具》在数字文档处理领域,PDF到图像格式的转换是常见需求,本文介绍如何利用Python的PyMuPDF库和Tkinter框架开发一个带图形界面的PDF转P... 目录一、引言二、功能特性三、技术架构1. 技术栈组成2. 系统架构javascript设计3.效果图