Skip to main content
No Result Found
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

Hybrid load testing using Selenium Python with JMeter or k6

Run a hybrid load test using Selenium Python (pytest) scripts on BrowserStack Load Testing

Prerequisites

  • BrowserStack Username and Access key. You can find this under your account profile.
  • An existing JMeter script and an automated test suite written in Selenium with Python and pytest.

Run a test

You can start a new test either from the Quick Start page, or the Load Tests page on the Load testing dashboard.

On the dashboard, click Create Load Test.

Screenshot of load testing dashboard showing the run a new test button highlighted

Enter a Test Name for your load test, select Hybrid and click Upload scripts.

Dashboard showing test name field and type of load test to run

Upload your scripts

The product runs a hybrid test using JMeter and Selenium Python automation projects. JMeter is used to generate API-level load, and Selenium drives browser-level load to simulate real user interactions.

Before you zip and upload your Selenium Python automation project for a hybrid load test, replace any local WebDriver instances (such as webdriver.Chrome()) with RemoteWebDriver (or an equivalent remote WebDriver factory) so tests run on the remote setup used by BrowserStack Load Testing. Set the remote URL to http://localhost:4444/wd/hub.

Example (conceptual) Use a remote WebDriver endpoint instead of a local driver so that the same tests can be reused across your Selenium Python and load testing setups.

You see two sections:

  • JMeter Script: Upload your JMeter .jmx file (up to 50MB). Drag and drop your file or click to select it.
  • Automation Project: Select Selenium - Python (or Selenium - Pytest) from the dropdown as your automation framework. Then, upload your zipped project files (.zip up to 250MB). Drag and drop the file or click to select it.

Screenshot of load testing dashboard asking to add scripts for load testing

Both fields are mandatory for their respective test types. After uploading, click Configure Load to proceed to the next step.

You can also run hybrid load tests using Selenium Python sample scripts if you want to try out the feature before uploading your own project.

You can configure the following load parameters to customize your load test:

Run test

After you finish configuring load parameters, click RUN TEST.

Install BrowserStack Python SDK

Execute the following commands to install BrowserStack Python SDK for plug-and-play integration of your test suite with BrowserStack.

python3 -m pip install browserstack-sdk
browserstack-sdk setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"
python3 -m pip install browserstack-sdk
browserstack-sdk setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"

Initialize your project for Load Testing

Run the following command from the root directory of your Selenium Python test project to generate the browserstack-load.yml file, which contains the configuration required to define and run your hybrid load test:

Copy icon Copy

Refer to the given table to use the framework - language combination argument depending on your preference:

Framework Argument
Selenium - Python --framework selenium --language python
Selenium - Pytest --framework pytest --language python

Configure your load test

Open the generated browserstack-load.yml file and update it with the relevant Selenium Python and JMeter test details. Use it to define your virtual users, duration, load profile, and regions.

Specify number of virtual users

Set vus to the maximum number of virtual users to simulate during the test. The max limit for this config is currently 100. Contact us if you want to increase this limit.

Before running a full-scale load test, do a sanity check with a small set of virtual users to validate your configuration and test stability.

Specify the tests

  • The tests block defines the combination of test types you want to run as part of a hybrid load test. Specify Selenium as the testType for one sub-block and JMeter for another.
  • For the Selenium sub-block,
    • browserLoadPercent - Specify the percentage of total virtual users to be allocated for Selenium tests.
    • language - Set this to python.
    • framework - Set this to pytest.
    • files - Define the key files needed to install dependencies and identify which tests to execute.
      • Under dependencies, include the path to files required for environment setup. For Selenium Python projects, this is typically requirements.txt.
      • Under runTarget, provide the path to your pytest entry point (for example, tests or tests/test_login.py).
  • For the JMeter sub-block,
    • apiLoadPercent - Specify the percentage of total virtual users to be allocated for JMeter tests.
    • testScripts - Set the path to the .jmx file.

Set reporting structure

Use projectName to group related tests under the same project on the dashboard. Use testName to group multiple runs of the same test.
Both projectName and testName must remain consistent across different runs of the same test.
You can use the following characters in projectName and testName:

  • Letters (A–Z, a–z)
  • Digits (0–9)
  • Periods (.), colons (:), hyphens (-), square brackets ([]), forward slashes (/), at signs (@), ampersands (&), single quotes ('), and underscores (_)
    All other characters are ignored.

You can configure the following load parameters to customize your load test:

Run the load test

Run the given command to start your test from the root of your Selenium Python project:

Copy icon Copy

Before running a full-scale hybrid load test, do a sanity check with a small set of virtual users to validate your Selenium Python configuration, k6 or JMeter setup, and test stability.

View test results

When the test is run, you get a link to the result dashboard where you can analyze key metrics like:

  • Response time
  • Request throughput
  • Web vitals (LCP, CLS, INP, and others)
  • Errors and bottlenecks

Prerequisites

  • BrowserStack Username and Access key. You can find this under your account profile.
  • An existing k6 script and an automated test suite written in Selenium with Python and pytest.

Run a test

You can start a new test either from the Quick Start page, or the Load Tests page on the Load testing dashboard.

On the dashboard, click Create Load Test.

Screenshot of load testing dashboard showing the run a new test button highlighted

Enter a Test Name for your load test, select Hybrid and click Upload scripts.

Dashboard showing test name field and type of load test to run

Upload your scripts

The product runs a hybrid test using k6 and Selenium Python automation projects. k6 is used to generate API-level load, and Selenium drives browser-level load to simulate real user interactions.

Before you zip and upload your Selenium Python automation project for a hybrid load test, replace any local WebDriver instances (such as webdriver.Chrome()) with RemoteWebDriver (or an equivalent remote WebDriver factory) so tests run on the remote setup used by BrowserStack Load Testing. Set the remote URL to http://localhost:4444/wd/hub.

Example (conceptual) Use a remote WebDriver endpoint instead of a local driver so that the same tests can be reused across your Selenium Python and load testing setups.

You see two sections:

  • k6 Script: Upload your k6 .js file (up to 50MB). Drag and drop your file or click to select it.
  • Automation Project: Select Selenium - Python (or Selenium - Pytest) from the dropdown as your automation framework. Then, upload your zipped project files (.zip up to 250MB). Drag and drop the file or click to select it.

Screenshot of load testing dashboard asking to add scripts for load testing

Both fields are mandatory for their respective test types. After uploading, click Configure Load to proceed to the next step.

You can also run hybrid load tests using Selenium Python sample scripts if you want to try out the feature before uploading your own project.

You can configure the following load parameters to customize your load test:

Run test

After you finish configuring load parameters, click RUN TEST.

Install BrowserStack Python SDK

Execute the following commands to install BrowserStack Python SDK for plug-and-play integration of your test suite with BrowserStack.

python3 -m pip install browserstack-sdk
browserstack-sdk setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"
python3 -m pip install browserstack-sdk
browserstack-sdk setup --username "YOUR_USERNAME" --key "YOUR_ACCESS_KEY"

Initialize your project for Load Testing

Run the following command from the root directory of your Selenium Python test project to generate the browserstack-load.yml file, which contains the configuration required to define and run your hybrid load test:

Copy icon Copy

Refer to the given table to use the framework - language combination argument depending on your preference:

Framework Argument
Selenium - Python --framework selenium --language python
Selenium - Pytest --framework pytest --language python

Configure your load test

Open the generated browserstack-load.yml file and update it with the relevant Selenium Python and k6 test details. Use it to define your virtual users, duration, load profile, and regions.

Specify number of virtual users

Set vus to the maximum number of virtual users to simulate during the test. The max limit for this config is currently 100. Contact us if you want to increase this limit.

Before running a full-scale load test, do a sanity check with a small set of virtual users to validate your configuration and test stability.

Specify the tests

  • The tests block defines the combination of test types you want to run as part of a hybrid load test. Specify Selenium as the testType for one sub-block and k6 for another.
  • For the Selenium sub-block,
    • browserLoadPercent - Specify the percentage of total virtual users to be allocated for Selenium tests.
    • language - Set this to python.
    • framework - Set this to pytest.
    • files - Define the key files needed to install dependencies and identify which tests to execute.
      • Under dependencies, include the path to files required for environment setup. For Selenium Python projects, this is typically requirements.txt.
      • Under runTarget, provide the path to your pytest entry point (for example, tests or tests/test_login.py).
  • For the k6 sub-block,
    • apiLoadPercent - Specify the percentage of total virtual users to be allocated for k6 tests.
    • testScripts - Set the path to the .js file.

Set reporting structure

Use projectName to group related tests under the same project on the dashboard. Use testName to group multiple runs of the same test.
Both projectName and testName must remain consistent across different runs of the same test.
You can use the following characters in projectName and testName:

  • Letters (A–Z, a–z)
  • Digits (0–9)
  • Periods (.), colons (:), hyphens (-), square brackets ([]), forward slashes (/), at signs (@), ampersands (&), single quotes ('), and underscores (_)
    All other characters are ignored.

You can configure the following load parameters to customize your load test:

Run the load test

Run the given command to start your test from the root of your Selenium Python project:

Copy icon Copy

Before running a full-scale hybrid load test, do a sanity check with a small set of virtual users to validate your Selenium Python configuration, k6 or JMeter setup, and test stability.

View test results

When the test is run, you get a link to the result dashboard where you can analyze key metrics like:

  • Response time
  • Request throughput
  • Web vitals (LCP, CLS, INP, and others)
  • Errors and bottlenecks

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle