Running on a Selenium Grid
TDK Feature
This is not supported in Testim's visual editor.
Testim supports running your code in the following ways:
- Locally - in this case, Testim will automatically install a driver for Chrome and run your code.
- Remotely - on a selenium Grid.
It is technically possible to run your tests in a Chrome instance directly in your CI and indeed doing so with Testim will work. We do not recommend it because while it has some advantages like reducing latency - your CI server is not aware of how much resources the browser uses. This means that it does not scale and it generally provides an inferior experience than using a proper browser grid.
We recommend running your tests on a Selenium grid. Note that this does not mean that Testim will run your tests with Selenium necessarily - only that Selenium Grid is the method used in order to control starting and stopping the browser and the test.
Actual Technical How-To
The easiest option would be to run:
npm run ci
In your Testim Code generated project. This will automatically look for a grid called testim-grid
which you can configure from the Testim UI. This also integrates with third-party grids seamlessly like Saucelabs or BrowserStack.
Alternatively, you can run Testim Code on a grid by passing the --host
and --port
options. For example, running a test locally on Firefox can be done with:
# webdriver manager is installed from npm
$ webdriver-manager start &
$ testim -f ./test.js --host localhost --port 4444 -b firefox
You can pass any valid Selenium grid here. Note that this implies that the grid needs to be reachable from your browser.
More examples
# grid name - preferred and more maintainable
$ testim -f ./tests/*.js --grid testim-grid
# grid host and port - also supported
$ testim -f ./tests/*.js --host http://example.com/grid --port 4444
# local grid assuming webdriver-manager is running
$ testim -f ./test.js --host 127.0.0.1 --port 4444
Updated over 2 years ago