Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs with # in them are not evaluated #433

Closed
jbnunn opened this issue Jun 20, 2016 · 5 comments
Closed

URLs with # in them are not evaluated #433

jbnunn opened this issue Jun 20, 2016 · 5 comments

Comments

@jbnunn
Copy link

jbnunn commented Jun 20, 2016

I have an Angular app I'm testing, and any URL I add to the locustfile that has a # symbol in them are ignored.

@jbnunn jbnunn changed the title URLs with # in them are not tested URLs with # in them are not evaluated Jun 20, 2016
@edthedev
Copy link

It looks like the default HTTP client for Locust.io is 'requests', which does not support JavaScript interactions (it runs by sending pure HTTP verbs GET/POST to the server). I imagine this is the root cause of the issue you are seeing. Angular JS probably never sees the actions taken by Locust.io, since JavaScript events are not triggered. (# is usually used by JS frameworks such as Angular as a form of navigation within a page, by binding to JavaScript events on document.location.)

Setting up Selenium (http://selenium-python.readthedocs.io/) as a Locust HTTP client would likely resolve the issue. (Selenium does support JavaScript interactions, by passing all interactions through a browser instance).

At this moment, I have no idea how to set up Selenium as a Locust.io HTTP client. I stumbled across this issue while looking to see if anyone else has. If I run across anything promising in my search, I will come back and link it from here for your reference.

@edthedev
Copy link

edthedev commented Jun 21, 2016

Following the recipe at http://docs.locust.io/en/latest/testing-other-systems.html, but using Selenium, may solve this for you.

from selenium import webdriver

class SeleniumLocust(Locust):
    def __init__(self, *args, **kwargs):
        # Do any additional Selenium set up here, or maybe subclass like in the example, if needed.
        self.client = webdriver.Chrome()

class ApiUser(SeleniumLocust):

    host = "http://127.0.0.1:8877/"
    min_wait = 100
    max_wait = 1000

    class task_set(TaskSet):
        @task(10)
        def stuff(self):
            # Do stuff here, but now self.client. supports anything that Selenium WebDriver does. It matches requests closely, but adds 'click' and some other JS events.
            pass

In theory, anyway.

@cgoldberg
Copy link
Member

driving multiple browsers via selenium is a bad idea if you want any sort of realistic performance results.

@heyman
Copy link
Member

heyman commented Jun 23, 2016

The hash fragments part of the URL is only displayed in browsers, and never sent to the server.

You won't be able to simulate more than a few simultaneous users if you run a Selenium browser for each user, and the results won't be realistic like @cgoldberg says.

My recommendation would be to make requests to the actual URLs which Angular requests behind the scenes (you can see these requests in the network tab in the developer tools of Chrome or Firefox).

@heyman heyman closed this as completed Jun 23, 2016
@jbnunn
Copy link
Author

jbnunn commented Jun 27, 2016

Thanks all--makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants