import random
import threading
import requests
#性能测试三要素:接口测试,多线程,真实场景
#真实场景:1、数据真实 2、用户操作链路真实 业务操作逻辑、思考时间
import time
class login():
def __init__(self):
pass
def firstpage(self):
url='http://localhost:8080/WoniuSales-20171128-V1.3-bin/'
res=requests.request('get',url=url)
if '请先登录' in res.text:
print('已经进入首页')
else:
print('进入首页失败')
def homepage(self):
url='http://localhost:8080/WoniuSales-20171128-V1.3-bin/sell'
res=requests.request('get',url=url)
if '注销' in res.text:
print('已经进入主页')
else:
print('进入主页失败')
def login(self,data):
url='http://localhost:8080/WoniuSales-20171128-V1.3-bin/user/login'
#data={'username': username,'password': password,'verifycode': '0000'}
res=requests.request('post',url=url,data=data)
if 'pass' in res.text:
print('登录成功')
else:
print('登录失败')
def start(self):
self.firstpage()
time.sleep(3)
self.login()
time.sleep(1)
self.homepage()
def thre(self):
for i in range(10):
tt=login()
user=[
{'username': 'admin','password': 'admin123','verifycode': '0000'},
{'username': 'zhangsan','password': 'zs123','verifycode': '0000'},
{'username': 'lisi','password': 'ls123','verifycode': '0000'},
{'username': 'wangwu','password': 'ww123','verifycode': '0000'},
{'username': 'boss','password': 'boss123','verifycode': '0000'}
]
indexc=random.randint(0,len(user)-1)
thre=threading.Thread(target=tt.login,args=(user[indexc],)) #线程
thre.start()
if __name__ == '__main__':
login().thre()
线程及其它代码
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...