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

Browser is not starting in headless mode #162

Closed
kolo-vrat opened this issue Jan 19, 2024 · 1 comment
Closed

Browser is not starting in headless mode #162

kolo-vrat opened this issue Jan 19, 2024 · 1 comment

Comments

@kolo-vrat
Copy link
Contributor

kolo-vrat commented Jan 19, 2024

As mentioned in the title the browser does not start in headless mode despite overriding the headless user class variable. After inspecting the Selenium Server logs I noticed that the --headless option is not passed down. The issue can be fixed if the --headless option is added as an argument to the options instead of assigning it as a property.

Here is portion of the logs:

12:51:48.865 INFO [LocalDistributor.newSession] - Session request received by the Distributor: 
 [Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--disable-translate, --disable-extensions, --disable-background-networ..., --safebrowsing-disable-auto..., --disable-sync, --metrics-recording-only, --disable-default-apps, --no-first-run, --disable-setuid-sandbox, --hide-scrollbars, --no-sandbox, --no-zygote, --autoplay-policy=no-user-g..., --disable-notifications, --disable-logging, --disable-permissions-api, --ignore-certificate-errors], excludeSwitches: [enable-automation], extensions: []}, pageLoadStrategy: eager}]
12:51:50.739 INFO [LocalNode.newSession] - Session created by the Node. Id: 4b29f0e02bb7d3f731c8ef7c865f74fc, Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 120.0.6099.199, chrome: {chromedriverVersion: 120.0.6099.109 (3419140ab66..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:44391}, networkConnectionEnabled: false, pageLoadStrategy: eager, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://192.168.0.14:4444/sess..., se:cdpVersion: 120.0.6099.199, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}

Environment

OS

Ubuntu 22.04.3 LTS x86_64

Python

3.11.7

Selenium Server

selenium-server-4.16.1.jar

Chrome WebDriver

120.0.6099.109

Packages

locust==2.20.1
locust-plugins==4.3.2
selenium==4.16.0

Code

Here is my locustfile.py

class MyUser(WebdriverUser):  
    wait_time = constant(2)  
    headless = True  
    tasks = [Tasks]

Fix

I fixed this issue by modifying the locust_plugins/users/webdriver.py file.

From:

options.headless = self.user.headless

To:

if self.user.headless:
    options.add_argument("--headless")
@cyberw
Copy link
Collaborator

cyberw commented Jan 19, 2024

I have kind of given up on the webdriver stuff (instead using playwright, if any browser tests at all..), but if you make a PR I will be happy to merge it :)

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