nickboucart / realbrowserlocusts

Real Browser support for Locust.io load testing
MIT License
91 stars 44 forks source link

HeadlessChrome #4

Open infratrezo opened 6 years ago

infratrezo commented 6 years ago

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!

brian-lim-42 commented 4 years ago

@infratrezo Thank You