How to clear cookies at end of locust.io user workflow

Viewed 1156

We are really new to locust.io and have setup a load test that allows a user to checkout on an e-commerce website. At the orderconfirmation page we are wanting/needing to clear the users cookies at the end of its run so when it starts over there are no saved cookies. It would be awesome to get some help on this! Python unfortunately is not a language i use on a daily basis so i'm sure this is something simple someone can help with!

class CheckoutPage(TaskSet):

  @task(1)
  def checkout(self):
    self.client.get("/Checkout/OrderConfirmation")
    # I want to clear cookies here so the httpuser starts over with no cookies

1 Answers

self.client is an instance of HttpSession, which is a wrapper for a requests.Session, so you can do:

self.client.cookies.clear()

Related