dongtang1997
2017-11-15 15:19
浏览 61
已采纳

在Laravel应用程序上进行Locust登录测试

Trying to login to laravel application using Locust. My code is following:

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
  def on_start(self):
    self.login()

  def login(self):
    response = self.client.get("/en/login")
    csrftoken = response.cookies['XSRF-TOKEN']
    session = response.cookies['bitrent_session']
    post_data = {'username': "user@user.com", 'password': '1234', "_token":     csrftoken }
    with self.client.post('/en/login', post_data,
                    catch_response=True) as response:
      print("Code: ", response.status_code)
      print("Content: ", response.content

  @task()
  def index(self):
    self.client.get("/")

class WebsiteUser(HttpLocust):
  task_set = UserBehavior
  min_wait = 5000
  max_wait = 9000

However I got error - Code 419 Content The page has expired due to inactivity. Could anyone advise me how to login to Laravel application using Locust

图片转代码服务由CSDN问答提供 功能建议

尝试使用Locust登录laravel应用程序。 我的代码如下: < pre> 来自locust import HttpLocust,TaskSet,task class UserBehavior(TaskSet): def on_start(self): self.login() def login(self): 响应 = self.client.get(“/ en / login”) csrftoken = response.cookies ['XSRF-TOKEN'] session = response.cookies ['bitrent_session'] post_data = {'username':“ user@user.com“,'password':'1234',”_ token“:csrftoken} ,其中self.client.post('/ en / login',post_data, catch_response = True)作为响应: print(“Code:”,response.status_code) print(“Content:”,response.content @task() def index(self): self.client.get(“/” ) class WebsiteUser(HttpLocust): task_set = UserBehavior min_wait = 5000 max_wait = 9000

但是我收到错误 - Code 419 Content 该页面由于不活动而过期。 任何人都可以告诉我如何 使用Locust 登录Laravel应用程序

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题