You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class CartPage(TaskSet):
@task(1)
def apply_promo_to_cart(self):
# stuff here
@task(1)
def remove_item_from_cart(self):
# stuff here
class ProductPage(TaskSet):
tasks = {CartPage:1}
@task(1)
def change_product_color(self):
# stuff here
@task(1)
def add_product_to_cart(self):
# stuff here
class WebsiteUser(HttpLocust):
task_set = ProductPage
min_wait = 1000
max_wait = 5000
When the locust enters the ProductPage TaskSet how do i ensure that anytime the "add_product_to_cart" method is called locust then starts using the CartPage TaskSet. Essentially In the browser when the user hits the button to add product to cart they go to the cart page and i want the locust to behave the same way. Right now it's sometimes executing change_product_color and then trying to go to the cart but it's empty!
The text was updated successfully, but these errors were encountered:
@TraGicCode In your example above you could just add self.schedule_task(CartPage, first=True) to the end of your add_product_to_cart() task and get the behavior you're looking for.
Although if you leave tasks = {CartPage: 1} (weight 1) the locust will still be able to go from change_product_color to CartPage.remove_item_from_cart. One way of solving this would be to have the weight of CartPage be 0, meaning the locust will never automatically schedule CartPage unless it hits add_product_to_cart first.
Alternatively you could just use sequential tasks instead:
I have the below locustfile
When the locust enters the ProductPage TaskSet how do i ensure that anytime the "add_product_to_cart" method is called locust then starts using the CartPage TaskSet. Essentially In the browser when the user hits the button to add product to cart they go to the cart page and i want the locust to behave the same way. Right now it's sometimes executing change_product_color and then trying to go to the cart but it's empty!
The text was updated successfully, but these errors were encountered: