Skip to content

Allow multiple dropdown in Web UI#3261

Merged
cyberw merged 8 commits intolocustio:masterfrom
jFompe:webui-arguments-select-multiple
Nov 17, 2025
Merged

Allow multiple dropdown in Web UI#3261
cyberw merged 8 commits intolocustio:masterfrom
jFompe:webui-arguments-select-multiple

Conversation

@jFompe
Copy link
Copy Markdown
Contributor

@jFompe jFompe commented Nov 8, 2025

Addresses #3260

This adds web UI support for a dropdown list in custom arguments with multiple selection:
image

Code:

parser.add_argument("--endpoints", choices=["status", "test", "users"], is_multiple=True, default=["status"], help="Endpoints")

Testing

I ran locally with run-local-web.sh and run-local-headless.sh on Ubuntu 24.04 in a virtual env with Python 3.12.3.

Also I added 3 tests to test_web.py and ran the file with pytest locust/test/test_web.py. All the tests passed.

Also used this code to check that the parsed value was always the expected one:

@events.test_start.add_listener
def on_test_start(environment, **kwargs):
    endpoints = environment.parsed_options.endpoints
    print(f"Argument endpoints. Type: {type(endpoints)}. Value: {endpoints}")

Tests with run-local-web.sh

Web UI mode, select multiple:
Argument endpoints. Type: <class 'list'>. Value: ['status', 'test', 'users']

Web UI mode, select one:
Argument endpoints. Type: <class 'list'>. Value: ['users']

Tests with run-local-headless.sh

Headless mode, select one.

"${VIRTUAL_ENV}/bin/python" -m locust \
  --locustfile "${script_dir}/locustfile.py" \
  --endpoints users \
  --headless \
  --host "https://example.com" \
  --loglevel "INFO"

Argument endpoints. Type: <class 'list'>. Value: ['users']

Headless mode, select multiple.

"${VIRTUAL_ENV}/bin/python" -m locust \
  --locustfile "${script_dir}/locustfile.py" \
  --endpoints users status \
  --headless \
  --host "https://example.com" \
  --loglevel "INFO"

Argument endpoints. Type: <class 'list'>. Value: ['users', 'status']

NOTE: for using this in headless mode it is necessary to add nargs='+' in add_argument.
For example:

parser.add_argument("--endpoints", nargs='+', choices=["status", "test", "users"], is_multiple=True, default=["status"], help="Endpoints")

@cyberw
Copy link
Copy Markdown
Collaborator

cyberw commented Nov 15, 2025

Looks cool! Regarding the test cases, can you merge it with one of the existing ones (maybe even merge some of the other test_swarm_custom_argument_* ones too)? They have a fair amount of overhead for every launch and we dont wanna make the tests even slower :)

@andrewbaldwin44 Can you review from a frontend perspective? (no rush)

@andrewbaldwin44
Copy link
Copy Markdown
Collaborator

LGTM I think this is a great addition!

@jFompe
Copy link
Copy Markdown
Contributor Author

jFompe commented Nov 16, 2025

@cyberw I just merged all the test_swarm_custom_argument_* tests into one. Let me know if I need to change anything else.

@cyberw cyberw merged commit 8fff651 into locustio:master Nov 17, 2025
18 checks passed
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

Successfully merging this pull request may close these issues.

3 participants