Testmo can be used with any test automation tool, including browser automation cloud services such as BrowserStack. This article provides an overview of using Testmo with Selenium & BrowserStack to run your browser tests and submit test results to implement BrowserStack test management.
BrowserStack is used with a browser automation library such as Selenium to automate web browsers. Selenium itself is not directly a test automation framework (it is a general purpose browser automation tool) so you would use an additional testing framework to run tests and report results.
Writing a complete test automation suite is outside of the scope of this article, but we have multiple complete articles on writing tests with Selenium and integrating the test suite with various services. So if you are not yet familiar with Selenium and don't have a test suite yet, please review our articles on getting started with your first Selenium tests:
You can also find fully working example projects for the above articles on GitHub. Please review the relevant code repositories here:
To submit and report test results to Testmo, you execute your automated tests and generate a JUnit-style XML report file. This file format has become a standard format to exchange test results between tools and is supported by practically any testing tool. Testmo also directly supports this format so it's very easy to report your test automation results.
$ npm run test-junit
> npx mocha test.mjs
✔ should search for "Selenium"
✔ should search for "Appium"
✔ should search for "Mozilla"
✔ should search for "GitHub"
✔ should search for "GitLab"
5 passing (7ms)
The above command runs the
test-junitscript alias we defined for the project, which instructs Mocha/CHai to run our tests and write all test results to an XML file. We are also running our tests against browsers running on BrowserStack. If you use a different programming language you would use the same approach here. We have links to documentation for many test automation frameworks on generating the correct file format.
We have now successfully executed our test automation suite and generated the report XML file with our test results. To submit the test results to Testmo, you simply use our cross-platform
testmoCLI tool. The CLI tool is distributed as an NPM package and is easy to install on any system. Simply install our official
$ npm install -g @testmo/testmo-cli
$ testmo -h
Usage: testmo [options] [command]
The CLI tool supports various commands and the easiest way to submit a complete test automation run is to use the
automation:run:submitcommand. This command creates a new automation run, submits all results and then marks the run as completed.
$ export TESTMO_TOKEN=********
$ testmo automation:run:submit \
--instance https://<your-name>.testmo.net \
--project-id 1 \
--name "BrowserStack test run" \
--source "frontend" \
If you run this example on a single command line, make sure to remove the backspaces:
$ export TESTMO_TOKEN=********
$ testmo automation:run:submit --instance https://<your-name>.testmo.net --project-id 1 --name "BrowserStack test run" --source "frontend" --results results/*.xml
On Windows, the command line uses a slightly different syntax to set a variable:
> set TESTMO_TOKEN=********
> testmo automation:run:submit --instance https://<your-name>.testmo.net --project-id 1 --name "BrowserStack test run" --source "frontend" --results results/*.xml
Collecting log files ..
Found 1 result file with a total of 855 tests
Created new automation run (ID: 254)
Created new thread (ID: 608)
Sending tests to Testmo ..
Uploading: [|||||||||||||||||||||||||] 100% | ETA: 0s | 855/855 tests
Successfully sent tests and completed run
Marked the run as completed
You need an API key for your Testmo user (or for a separate API user) to authenticate and submit your test results. Learn more about generating API keys.
This is just a basic example of using Testmo with Selenium and BrowserStack. The
testmotool also supports various other features, such as launching your test automation tool directly to capture the console output, record exit codes and measure test times. You can also submit additional fields, artifacts and links with your test runs. See the full documentation for more details.
Testmo also supports advanced test automation workflows such as submitting test runs for multiple test suites and reporting parallel test execution. You can also report your test automation runs from your CI pipeline and build systems. See the following guides and examples on further topics:
We have additional guides on how to integrate and submit your automated test results to Testmo from various popular CI/CD services and build tools: