Docs

Running browsers in clouds and grids

Selenium Grid, Testcontainers, TestMu AI, BrowserStack, Sauce Labs, Moon, Selenoid: switching to a remote browser takes one setting.

The easiest, fastest and most reliable way is to run the browser on the same machine as the test (a “local” run), or in a Docker container on the same machine.

But people don’t always look for easy ways. Sometimes they want to run browsers in the cloud. In theory, that gives you some advantages: virtually unlimited scaling and many versions of many browsers. It also brings difficulties and limitations, of course.

Selenide makes it easy either way. To run a browser remotely, use the remote setting:

Configuration.remote = "https://your-cloud-provider.com/wd/hub";

Selenium Grid

Written in Java by the Selenium team.

How to use:

<dependency>
  <groupId>com.codeborne</groupId>
  <artifactId>selenide-grid</artifactId>
  <version>7.19.3</version>
</dependency>

Pros:

  • Works without Docker. Supports all browsers (that have a WebDriver) of any version.
  • Scalable: you can run many nodes on different operating systems, with different browser versions.
  • You can run it on your own servers or locally.

Cons:

  • Doesn’t support clipboard operations.

Testcontainers

Runs a browser in a Docker container with just one annotation.

A working example: selenide-examples/testcontainers.

Pros:

  1. Runs different browser versions.
  2. Can record video of the test run (plus many other Testcontainers features).
  3. Most Selenide features still work: screenshots, proxy, CDP etc.

Cons:

  1. Some Selenide features may not work (e.g. clipboard).
  2. Only browsers that can run in Docker are supported (Safari can’t).

TestMu AI (ex. LambdaTest)

A working example: selenide-examples/selenide-lambdatest. Website: testmu.ai.

Selenide tests that run the browser on TestMu AI servers. As you can see, the setup is minimal:

Configuration.remote = "https://hub.lambdatest.com/wd/hub";
Configuration.browserCapabilities.setCapability("LT:Options", Map.of(
  "user", "unclebob",
  "accessKey", "0123456789001234567890"
));

Pros:

  1. Runs different browser versions.

Cons:

  1. Some Selenide features may not work (e.g. clipboard, proxy, downloading to a folder).

BrowserStack

A working example: selenide-examples/selenide-browserstack. Website: browserstack.com.

Selenide tests that run the browser on BrowserStack servers. Again, the setup is minimal:

Configuration.remote = "https://hub-cloud.browserstack.com/wd/hub";
Configuration.browserCapabilities.setCapability("bstack:options", Map.of(
  "userName", "unclebob",
  "accessKey", "0123456789001234567890"
));

Pros:

  1. Runs different browser versions.

Cons:

  1. Some Selenide features may not work (e.g. clipboard, proxy, downloading to a folder).

Sauce Labs

Sauce Labs also runs browsers and mobile apps on its servers.

A working example: selenide-examples/selenide-saucelabs. Website: saucelabs.com.

Pros:

  1. Runs different browser versions.

Cons:

  1. Some Selenide features may not work (e.g. clipboard, proxy).

Moon

Like Selenium Grid, but in Docker (Kubernetes). It’s written in Go, so it’s fast and uses little memory.

How to use:

<dependency>
  <groupId>com.codeborne</groupId>
  <artifactId>selenide-moon</artifactId>
  <version>7.19.3</version>
</dependency>

Pros:

  1. Directly supported by Selenide.
  2. Supports Selenide features that may not work in other clouds: clipboard, downloading files.
  3. Runs different browser versions.
  4. Can record video of the test run.

Cons:

  1. Only browsers that can run in Docker are supported (Safari can’t).

Selenoid

Like Selenium Grid, but in Docker. It’s written in Go, so it’s fast and uses little memory.

How to use:

<dependency>
  <groupId>com.codeborne</groupId>
  <artifactId>selenide-selenoid</artifactId>
  <version>7.19.3</version>
</dependency>

Pros:

  1. Directly supported by Selenide.
  2. Supports Selenide features that may not work in other clouds: clipboard, downloading files.
  3. Runs different browser versions.
  4. Can record video of the test run.

Cons:

  1. Only browsers that can run in Docker are supported (Safari can’t).

Other cloud providers

In theory, other cloud providers should integrate just as easily.

Which providers have you tried? Pros, cons, pitfalls? Tell us and share the code.

And most importantly: was it worth it? Tell us what problems running browsers remotely solves for you, and why it was worth giving up speed, convenience and some features.

Didn't find the answer?

Ask the community, we answer fast: Selenide examples · Telegram · Report an issue