包含“/#/”的URL请求都被视为“/”,然后在Locust.i上运行时失败

2024-06-23 19:49:27 发布

您现在位置:Python中文网/ 问答频道 /正文

包含“/#/”的请求都被视为“/”。然后我会得到一大堆“失败”。你知道吗

from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):

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

@task(1)
def dashboard_page(self):
    self.client.get("/#/bubblesu")

@task(1)
def parents_page(self):
    self.client.get("/#/pages/parents")

class WebsiteUser(HttpLocust):
    task_set = UserBehavior

这是结果enter image description here

提示中没有cmd错误。你知道吗

然后,我试图说服蝗虫命名(和使用)正确的。 尽管命名有效,但看起来请求仍然针对“/”。因此,结果我无法对每个请求进行负载测试。你知道吗

我的开发人员说“散列符号在那里,因为它是一个单页应用程序 之后的路径仅用于通过javascript进行路由。如果您将其删除,浏览器将尝试查找该页“

这是剧本

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):

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

    @task(1)
    def dashboard_page(self):
        self.client.get("/#/bubblesu", name='dashboard')

    @task(1)
    def parents_page(self):
        self.client.get("/#/pages/parents", name='parents')

class WebsiteUser(HttpLocust):
    task_set = UserBehavior

从cmd执行。你知道吗

locust -f locustfile2.py --host=https://www.bubblesu.com

这是登录页的URL。你知道吗

https://bubblesu.com/#/bubblesu

这就是蝗虫所展示的。 enter image description here

cmd没有显示错误。你知道吗

使用windows10,Pycharm


Tags: selfcmdclienttaskgetdefpageclass

热门问题