Giter Club home page Giter Club logo

realbrowserlocusts's People

Contributors

colinfwren avatar knmorgan avatar nickboucart avatar pgrabusz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

realbrowserlocusts's Issues

can not run

Hi ,
I have tried to run your example as is but getting error of Could not find any locustfile! Ensure file ends in '.py'.

I can run other locust files perfectly but your example I can not run. is there any set up i need to do?

Exception in task method is handled but not reported as a failure

Hi,

If an unhandled exception occurs in a task method it is handled by the framework and
tasks continue to be executed by the Realbrowserlocusts but not reported as a failure. If you are
only looking at the final success/failure rate - perhaps programmatically - it is easier
to miss the exception.
Especially when wait throw timeout exception raise TimeoutException(message, screen, stacktrace)
My log selenium.common.exceptions.TimeoutException: Message:
TypeError: on_request_failure() missing 1 required positional argument: 'response_length'
result = func(*args, **kwargs)
selenium.common.exceptions.TimeoutException: Message:

Thanks,

Maybe integrate this into locust-plugins?

Hi @nickboucart !

I'm one of the maintainers of Locust and the creator of "locust-plugins", a collection of addons for locust.

Before I found your code, I made my own "WebdriverLocust" as part of "my" package (see https://github.com/SvenskaSpel/locust-plugins/blob/66c880057576634711fb3a5ed26c72dde086d942/locust_plugins/users.py#L98 / https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/webdriver.py).

I think yours looks a lot better, with its built in support for multiple browsers and proper timing measurements.

Would you consider contributing it to "my" repo? (released under the apache license). You would of course be credited, and if you want I can add you as maintainer for the repo.

Cannot run a demo file

I've installed python3.6 + locust.io + realbrowserlocusts on an AWS EC2 running ubuntu & python 3.6
I can run a demo from the locust.io web page.
However, when I try to run the demo from realbrowserlocusts, it sends an error:

  File "/usr/local/bin/locust", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 113, in main
    docstring, user_classes = load_locustfile(locustfile)
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 77, in load_locustfile
    imported = __import_locustfile__(locustfile, path)
  File "/usr/local/lib/python3.6/dist-packages/locust/main.py", line 53, in __import_locustfile__
    return  source.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ubuntu/reallocusts.py", line 1, in <module>
    from realbrowserlocusts import FirefoxLocust, ChromeLocust, PhantomJSLocust
  File "/usr/local/lib/python3.6/dist-packages/realbrowserlocusts/__init__.py", line 3, in <module>
    from realbrowserlocusts.locusts import FirefoxLocust, PhantomJSLocust, \
  File "/usr/local/lib/python3.6/dist-packages/realbrowserlocusts/locusts.py", line 7, in <module>
    from realbrowserlocusts.core import RealBrowserClient
  File "/usr/local/lib/python3.6/dist-packages/realbrowserlocusts/core.py", line 6, in <module>
    from locust.exception import StopLocust

Seems to me that I have something missing.
I´m not familiar with python.

TypeError: __init__() takes 1 positional argument but 2 were given

I am using Locust version 1.3.1. when I ran this demo with this version, I am facing issues with greenlet package. I am not sure what is wrong. I also modified the demo code to match locust latest version. For example,

from locust import Locust to from locust import User

Traceback (most recent call last):
File "src\gevent\greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 401, in
lambda: super(LocalRunner, self).start(user_count, spawn_rate, wait=wait)
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 312, in start
self.spawn_users(user_count, spawn_rate=spawn_rate, wait=wait)
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 204, in spawn_users
spawn()
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 197, in spawn
new_user = user_class(self.environment)
TypeError: init() takes 1 positional argument but 2 were given
2020-10-20T15:45:48Z <Greenlet at 0x2445066b8c0: > failed with TypeError

[2020-10-20 21:15:48,809] System/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x2445066b8c0: >
Traceback (most recent call last):
File "src\gevent\greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 401, in
lambda: super(LocalRunner, self).start(user_count, spawn_rate, wait=wait)
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 312, in start
self.spawn_users(user_count, spawn_rate=spawn_rate, wait=wait)
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 204, in spawn_users
spawn()
File "c:\work\projects\careercompass\flask-testing\env\lib\site-packages\locust\runners.py", line 197, in spawn
new_user = user_class(self.environment)
TypeError: init() takes 1 positional argument but 2 were given

HeadlessChrome

First of all: Thanks for this package, it's amazing :)
I ran into an issue when using HeadlessChrome though:

[2018-08-27 18:35:32,635] ip-172-24-16-136/ERROR/stderr: 2018-08-27T18:35:32Z
[2018-08-27 18:35:32,635] ip-172-24-16-136/ERROR/stderr: 
[2018-08-27 18:35:32,635] ip-172-24-16-136/ERROR/stderr: <Greenlet "Greenlet-0" at 0x7f6c8c9ab470: start_locust(<class 'selenium-locustfile.WebsiteUser'>)> failed with WebDriverException
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: Traceback (most recent call last):
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "src/gevent/greenlet.py", line 716, in gevent._greenlet.Greenlet.run
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/locust/runners.py", line 117, in start_locust
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: locust().run()
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/realbrowserlocusts/locusts.py", line 57, in __init__
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: driver = webdriver.Chrome(chrome_options=options)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: desired_capabilities=desired_capabilities)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: self.start_session(capabilities, browser_profile)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: response = self.execute(Command.NEW_SESSION, parameters)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 320, in execute
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: self.error_handler.check_response(response)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: File "/root/.virtualenv/locust/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: raise exception_class(message, screen, stacktrace)
[2018-08-27 18:35:32,836] ip-172-24-16-136/ERROR/stderr: WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.38 (undefined),platform=Linux 4.9.0-7-amd64 x86_64)

Adding these lines to locusts.py solved it for me:
def init(self):
super(HeadlessChromeLocust, self).init()
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

options.add_argument('window-size={}x{}'.format(
self.screen_width, self.screen_height
))

Cheers!

any support for docker build

with this real browser in single mechine I cann't actually do load testing as user will be limited to 30-40 for headless chrome .

some docker image would be helpfull

Playwright instead of Selenium?

Could you provide support for Playwright instead of Selenium? It uses the same Chromium browser but it's much more stable and the Codegen Utility used for rapid script development is extraordinary.

https://github.com/microsoft/playwright-python

The locust engine runs more efficient than any other than any other tool and it open the doors for many users to do some real great Browser-based load testing.

If you could also add in support for running in the cloud that would be great as well.
Azure - identifying the a subscription and resource group and for AWS it would be using Fargate.

Table of the results sorting and missing issues

Hi,

Realbrowserlocusts is sorting the results by name, I want the results to stay as the flow of the scenario.
so how can I get the control to make them stay as the flow of the scenario?

there are 2 columns stay empty always, the columns are: Content Size (bytes) and # reqs/sec
so how can locust fill them in the table of the results

image

Thanks,

Headless Firefox

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.