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

Headless Firefox #1

Open
so0k opened this issue Jul 17, 2016 · 4 comments
Open

Headless Firefox #1

so0k opened this issue Jul 17, 2016 · 4 comments

Comments

@so0k
Copy link

so0k commented Jul 17, 2016

Great module, it worked perfectly with PhantomJS in docker containers.

Although, PhantomJS seemed quite slow, so I tried to use firefox... and it was a pain due to display issues.

I ended up copying the sourecode into my project folder and modifying the locusts.py as follows:

+from pyvirtualdisplay import Display
...

class RealBrowserLocust(Locust):
    client = None
    timeout = 30
    screen_width = None
    screen_height = None
+   display = None

    def __init__(self):
        super(RealBrowserLocust, self).__init__()
        if self.screen_width is None:
            raise LocustError("You must specify a screen_width for the browser")
        if self.screen_height is None:
            raise LocustError("You must specify a screen_height for the browser")
+       self.display = Display(visible=0, size=(self.screen_width, self.screen_height))
+       self.display.start()
...
class FirefoxLocust(RealBrowserLocust):
    """
    This is the abstract Locust class which should be subclassed. It provides a Firefox webdriver that logs GET's and waits to locust
    """
    def __init__(self):
        super(FirefoxLocust, self).__init__()
        #binary = FirefoxBinary(firefox_path='/usr/bin/firefox',log_file=open("/firefox.log",'w'))
        #self.client = RealBrowserClient(webdriver.Firefox(firefox_binary=binary), self.timeout, self.screen_width, self.screen_height)
+       self.client = RealBrowserClient(webdriver.Firefox(), self.timeout, self.screen_width, self.screen_height)

I still have to find a way to stop the display when the locust client is killed...

But I wonder, how do you run the locust Firefox instance?

@brandonparncutt
Copy link

brandonparncutt commented Oct 13, 2017

@so0k You can use a virtual display...you need to install Xvdf and the pyvirtualdisplay python module. Then create a virtual display with visible param set to 0...the firefox web driver will then start firefox using that framebuffer. It's not exactly headless, but it doesn't require X or anything.

@nickboucart Thanks for this...I've been on the hunt for a better way to test AJAX-heavy single-page web apps and Locust has become my favorite tool for loadtesting. This was its only downfall.

@so0k
Copy link
Author

so0k commented Oct 15, 2017

I do believe I used Xvdf, but it was just too slow to run a high load test

@brandonparncutt
Copy link

@so0k I was actually curious about how adding the selenium jar and a browser to the mix was going to impact performance. The biggest reason why I chose Locust (over Jmeter, for example) was that I could perform a very intensive load test (borderline DOS attack) with just a quad-core laptop...and still be able to use it for other tasks. Do you recall the specs of your machine and the highest RPS you were able to generate?

@so0k
Copy link
Author

so0k commented Oct 17, 2017 via email

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

2 participants