locust cookie处理
2022/4/6 23:21:59
本文主要是介绍locust cookie处理,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、locust 实例中的self.client 指向了HTTPsession 类,只要服务端返回了cookie,默认就是可以自动处理cookie的
代码如下:
from locust import HttpUser, TaskSet, task, os class MyTask(TaskSet): def on_start(self): self.data1 = {"userName": "admin", "password": "1234"} response = self.client.post("/pinter/bank/api/login", data=self.data1, name="login") print(response.text) def on_stop(self): print("用户结束") @task def query_account(self): self.data2 = {"userName": "admin"} response = self.client.get("/pinter/bank/api/query", params=self.data2, name="quer_account") print(response.text) class WebsiteUser(HttpUser): tasks = [MyTask] host = "http://lcocalhost:8080" min_wait = 5000 max_wait = 9000 if __name__ == "__main__": os.system("locust -f CookieTest.py --host=http://localhost:8088")
这篇关于locust cookie处理的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28pyqt 怎么打包整个项目-icode9专业技术文章分享
- 2024-09-28laravel Commands 创建带有参数的 Artisan 命令的步骤和示例-icode9专业技术文章分享
- 2024-09-28antd怎么实现渲染tiff图片-icode9专业技术文章分享
- 2024-09-28英文半角中划线和中文全角的中划线有什么区别-icode9专业技术文章分享
- 2024-09-28nvm npm 和node 他们之间有什么关系-icode9专业技术文章分享
- 2024-09-28Node Version Manager (nvm)使用教程-icode9专业技术文章分享
- 2024-09-28nvm命令太慢,是什么原因-icode9专业技术文章分享
- 2024-09-28Kotlin 如何增加、删除和修改 MutableStateFlow 中的值。-icode9专业技术文章分享
- 2024-09-28Kotlin的stateFlow.update 写法介绍-icode9专业技术文章分享
- 2024-09-28kotlin 怎么获取当前时间格式-icode9专业技术文章分享