{"action":"created","issue":{"url":"https://api.github.com/repos/locustio/locust/issues/246","labels_url":"https://api.github.com/repos/locustio/locust/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/locustio/locust/issues/246/comments","events_url":"https://api.github.com/repos/locustio/locust/issues/246/events","html_url":"https://github.com/locustio/locust/issues/246","id":57836494,"number":246,"title":"Error to login to webapp in Locust","user":{"login":"casidos","id":5394612,"avatar_url":"https://avatars.githubusercontent.com/u/5394612?v=3","gravatar_id":"","url":"https://api.github.com/users/casidos","html_url":"https://github.com/casidos","followers_url":"https://api.github.com/users/casidos/followers","following_url":"https://api.github.com/users/casidos/following{/other_user}","gists_url":"https://api.github.com/users/casidos/gists{/gist_id}","starred_url":"https://api.github.com/users/casidos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/casidos/subscriptions","organizations_url":"https://api.github.com/users/casidos/orgs","repos_url":"https://api.github.com/users/casidos/repos","events_url":"https://api.github.com/users/casidos/events{/privacy}","received_events_url":"https://api.github.com/users/casidos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-16T18:20:21Z","updated_at":"2015-08-21T10:47:14Z","closed_at":null,"body":"I want locust to be able to login to my web application and start to click in the links inside the web application.\r\n\r\nWith this code I just get activity for the front page with the login and i don't get any notification from inside the application.\r\n\r\nCode:\r\n\r\n    import random\r\n    from locust import HttpLocust, TaskSet, task\r\n    from pyquery import PyQuery\r\n\r\n    class WalkPages(TaskSet):\r\n        def on_start(self):\r\n            self.client.post(\"/\", {\r\n                \"UserName\": \"my@email.com\",\r\n                \"Password\": \"2Password!\",\r\n                \"submit\": \"Sign In\"\r\n            })\r\n           self.index_page()\r\n\r\n    @task(10)\r\n    def index_page(self):\r\n        r = self.client.get(\"/Dashboard.mvc\")\r\n        pq = PyQuery(r.content)\r\n        link_elements = pq(\"a\")\r\n        self.urls_on_current_page = []\r\n        for l in link_elements:\r\n          if \"href\" in l.attrib:\r\n            self.urls_on_current_page.append(l.attrib[\"href\"])\r\n\r\n    @task(30)\r\n    def load_page(self):\r\n        url = random.choice(self.urls_on_current_page)\r\n        r = self.client.get(url)\r\n\r\n\r\n    class AwesomeUser(HttpLocust):\r\n        task_set = WalkPages\r\n        host = \"https://myenv.beta.webapp.com\"\r\n        min_wait = 20  * 1000\r\n        max_wait = 60  * 1000\r\n\r\nI get the follow msg in the terminal after the first round.\r\n\r\n[2015-02-13 12:08:43,740] webapp-qa/ERROR/stderr: Traceback (most recent call last):\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 267, in run\r\n    self.execute_next_task()\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 293, in execute_next_task\r\n    self.execute_task(task[\"callable\"], *task[\"args\"], **task[\"kwargs\"])\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 305, in execute_task\r\n    task(self, *args, **kwargs)\r\n  File \"/home/webapp/LoadTest/locustfile.py\", line 31, in load_page\r\n    url = random.choice(self.urls_on_current_page)\r\n  File \"/usr/lib/python2.7/random.py\", line 273, in choice\r\n    return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty\r\nIndexError: list index out of range\r\n[2015-02-13 12:08:43,752] webapp-qa/ERROR/stderr: Traceback (most recent call last):\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 267, in run\r\n    self.execute_next_task()\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 293, in execute_next_task\r\n    self.execute_task(task[\"callable\"], *task[\"args\"], **task[\"kwargs\"])\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 305, in execute_task\r\n    task(self, *args, **kwargs)\r\n  File \"/home/webapp/LoadTest/locustfile.py\", line 31, in load_page\r\n    url = random.choice(self.urls_on_current_page)\r\n  File \"/usr/lib/python2.7/random.py\", line 273, in choice\r\n    return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty\r\nIndexError: list index out of range\r\n[2015-02-13 12:08:43,775] webapp-qa/ERROR/stderr: Traceback (most recent call last):\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 267, in run\r\n    self.execute_next_task()\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 293, in execute_next_task\r\n    self.execute_task(task[\"callable\"], *task[\"args\"], **task[\"kwargs\"])\r\n  File \"/usr/local/lib/python2.7/dist-packages/locust/core.py\", line 305, in execute_task\r\n    task(self, *args, **kwargs)\r\n  File \"/home/webapp/LoadTest/locustfile.py\", line 31, in load_page\r\n    url = random.choice(self.urls_on_current_page)\r\n  File \"/usr/lib/python2.7/random.py\", line 273, in choice\r\n    return seq[int(self.random() * len(seq))]  # raises IndexError if seq is empty\r\nIndexError: list index out of range"},"comment":{"url":"https://api.github.com/repos/locustio/locust/issues/comments/133371437","html_url":"https://github.com/locustio/locust/issues/246#issuecomment-133371437","issue_url":"https://api.github.com/repos/locustio/locust/issues/246","id":133371437,"user":{"login":"kunalg","id":323316,"avatar_url":"https://avatars.githubusercontent.com/u/323316?v=3","gravatar_id":"","url":"https://api.github.com/users/kunalg","html_url":"https://github.com/kunalg","followers_url":"https://api.github.com/users/kunalg/followers","following_url":"https://api.github.com/users/kunalg/following{/other_user}","gists_url":"https://api.github.com/users/kunalg/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalg/subscriptions","organizations_url":"https://api.github.com/users/kunalg/orgs","repos_url":"https://api.github.com/users/kunalg/repos","events_url":"https://api.github.com/users/kunalg/events{/privacy}","received_events_url":"https://api.github.com/users/kunalg/received_events","type":"User","site_admin":false},"created_at":"2015-08-21T10:47:14Z","updated_at":"2015-08-21T10:47:14Z","body":"@casidos this part of the error list clearly says what's wrong:\r\n``` python\r\nFile \"/home/webapp/LoadTest/locustfile.py\", line 31, in load_page\r\nurl = random.choice(self.urls_on_current_page)\r\nFile \"/usr/lib/python2.7/random.py\", line 273, in choice\r\nreturn seq[int(self.random() * len(seq))] # raises IndexError if seq is empty\r\nIndexError: list index out of range\r\n```\r\nIt means that the list you're trying to build - self.urls_on_current_page - is empty.\r\n\r\n@echorohit did you decorate your tasks with the ```@task ``` decorator?\r\nWithout that, it never queues up the tasks and hence the error."}}