当前位置:网站首页>Millisecond upload batch attachments
Millisecond upload batch attachments
2022-07-23 05:48:00 【zsyzcsan】
This article tells : During the test , Upload batch attachments in milliseconds through automated scripts .
Be careful : This article requires you to have the following skills
- Test the basics
- python Programming knowledge
- Database knowledge
- Automation framework idea
During the test , Statistics show that all forms and pages of the tested system share 39 Attachments ( picture ) Need to upload ; Here's how it works :
- 1、 Form page , Click on “ Upload ” Button , Select the locally prepared attachment in the pop-up window ( picture ), In the case of skilled operation, it costs about 2 second ;
- 2、39 Zhang *2 second / Zhang =72 second
- 3、 During the test , Test data that needs to be constructed every day , It's about 30 strip
- 4、 hold 2 and 3 Multiplication is 72 second / strip *30 strip =2160 second , Reduced contract 36 minute , That is, just uploading attachments consumes me 36 minute ;
that , The problem is coming. “ I was angry …”
I try to upload attachments automatically , The result really surprised ;
“ A total of 39 Attachments , It took time 0.12213140000000003 second ”, notice pycharm Messages printed from the console , The author is very happy .
[2088-08-8 8:8:8] - INFO: It takes time to connect to the database 0.002419699999999997 second
......
[2088-08-8 8:8:9] - INFO: A total of 39 Attachments , It took time 0.12213140000000003 second .

In that case ,39 Zhang *0.122 second / Zhang =4.758 second ;
It seems , The speed of automation is about manual 454 times ;
that , How did the author achieve it ?
Don't worry , Stand firm and hold it well , Now let's roll up !
mysqlc.py
# -*- coding: utf-8 -*-
import pymysql.cursors
from common.myLog import *
from config.readConfig import *
import time
class mysql_do():
def __init__(self,db):
self.log = MyLog()
self.connect = pymysql.Connect(
# Read the database connection information of the test environment
host=self.dbinfo["host"],
port=int(self.dbinfo["port"]),
user=self.dbinfo["user"],
passwd=self.dbinfo["passwd"],
db= db,
charset='utf8'
)
self.cursor = self.connect.cursor()
time4 = time.perf_counter()
self.log.info(message=" It takes time to connect to the database %s second " % (time4 - time3))
def sqlselect3(self):
sqlselect1 = 'SELECT id from Table name 1 ORDER BY id DESC LIMIT 1'
sqlselect2 = 'SELECT id from Table name 2 ORDER BY id DESC LIMIT 1'
exe1= self.cursor.execute(sqlselect1)
res = self.cursor.fetchall()
exe2= self.cursor.execute(sqlselect2)
res1 = self.cursor.fetchall()
a_id = res[0][0]
ab_id = res1[0][0]
return a_id ,ab_id
def sqlselect3_insert(self,**kwargs):
time3 = time.perf_counter()
a= kwargs["a"]
sql = mysql_do(db = ' Table name ').sqlselect3()
b_id = [1,2,3,.....,39]
k = 0
for k in range (0,len(b_id )):
att_sql = b_id [k]
att_id = sql[0] + k +1
attachment_rel_id = sql[1] + k +1
i1 = "INSERT INTO ` Library name `.` Table name 1`(`id`, `name`, `url`, `alias`, `remark`, `tmp`, `created_by`, `created_date`, `deleted`, `last_modified_by`, `last_modified_date`) VALUES ({}, 'a.png', 'http://www.***/filepath/a.png', NULL, NULL, '/data/path/5000-04/a.png', NULL, NULL, 0, NULL, NULL)".format(att_id)
i2 = 'INSERT INTO ` Library name `.` Table name 2`(`id`, `data_id`, `at_id`, `at_type_id`, `remark`, `tmp`, `created_by`, `created_date`, `deleted`, `last_modified_by`, `last_modified_date`) VALUES ({}, {}, {}, {}, NULL, NULL, NULL, NULL, 0, NULL, NULL)'.format(atta_rel_id,a,att,att_sql)
k +=k
self.cursor.execute(i1)
self.cursor.execute(i2)
self.connect.commit()
self.log.info(message=" The attachment image was inserted successfully , Please check out ` Library name `.` surface 1` surface id={}、` Library name `.` surface 2` surface id={}".format(att_id,atta_rel_id) )
time4 = time.perf_counter()
self.log.info(message=" A total of {} Attachments , It took time {} second .".format(len(b_id ),(time4 - time3)))
self.connect.close()
边栏推荐
猜你喜欢
随机推荐
面向腾讯(实战)-测试开发-实习生(面经)详解
Freshman summer internship Day5_ three
自动测试和手动测试
Summary of SV knowledge points
一个简易的手机端todo
Camera roaming
Debug No2 按流程检查错误
unity中3dUI或者模型始終面向攝像機,跟隨攝像機視角旋轉丨視角跟隨丨固定視角
RPC-BDY(2)-注册多个服务
软件测试成长之路
软件测试流程
按照是否查看原代码划分: 白盒测试和黑盒测试
Lvgl: simulator simulation
动态规划A-1
train-clean-100 数据集
关于 以为自己 下载 torch 是GPU版本,结果确实cpu版本 的解决办法
Icm20948 conversion relationship between angular velocity reading of nine axis sensor and actual unit conversion
数据可视化的工具
2021-06-03pip报错 ValueError: Unable to find resource t64.exe in package pip._vendor.distlib
OpenGL create a new window









