Considering using a next generation continuous testing solution like mabl but are concerned about losing your existing Selenium tests? We have some great news. You can migrate a great portion of your Selenium-based tests to mabl and automatically make them self-healing, which immediately reduces future maintenance needs for those tests. All flavors of Selenium tests such as Java, Protractor, .NET, and Python can be migrated to mabl regardless of where the tests run in terms of browser and runtime environment (e.g. local/remote WebDriver, Selenium Grid, SauceLabs, Browserstack, etc.)
The migration tool enables you to retain a great deal of your investment in creating Selenium tests and allows you take full advantage of all mabl benefits sooner. However, it is important to note that the migration tool will import most of your Selenium test actions into mabl (e.g. clicks, enter text) but it will not be able to generate an exact replica of the original Selenium tests . For example, you will need to add your assertions in mabl since those will not be imported from the Selenium test.
The Selenium migration tool is part of the mabl CLI. At a high level, the tool starts a proxy server on port 8889 that sits between your tests and the runtime environment such as a remote WebDriver or Selenium Grid endpoint. When the tests runs, the import tool intercepts all of the Selenium network traffic between the two and translates those requests into mabl test steps.
To get started with the Selenium test migration, following these steps:
- Installation of the mabl CLI
- Minor modification to existing Selenium tests
- Start of an import session from the mabl CLI
- Execution of Selenium tests to be imported
- Saving imported tests in mabl
- Reviewing, updating and running tests in mabl
Here is a 2-minute video example about migrating tests from Protractor to mabl. Other Selenium-based frameworks follow a similar workflow.
The first step is to install mabl CLI or update to the latest version using the node package manager (NPM):
npm install -g @mablhq/mabl-cli
For the import to work, it is necessary to make a small configuration change to the tests so that the proxy running inside the mabl CLI can listen in to the Selenium traffic. The change that needs to be made varies based on the programming language and Selenium framework used.
For example, Protractor tests require a single line configuration change while Java Selenium needs the RemoteWebDriver instance to be initialized in a slightly different configuration to work with the proxy.
There are two options for migrating Java-based Selenium tests to mabl: the Java Selenium Agent, and the language-agnostic Selenium Proxy. If you are unsure which method to use, we recommend trying the Selenium Agent first because it does not require any changes to your Java code, and it is generally the easier option. See the following documentation pages for more information about each method:
Add the following setting to your Protractor configuration file:
Configure a proxy inside the remote web driver client (replace "
http://localhost:9515" with the URL of your remote web driver or Selenium Grid):
client = Selenium::WebDriver::Remote::Http::Default.new client.proxy = Selenium::WebDriver::Proxy.new(http: "http://localhost:8889") driver = Selenium::WebDriver.for :remote, http_client: client, url: "http://localhost:9515"
There is a Github repo with examples of modified Selenium tests ready for migration to mabl.
After you modify the Selenium tests, use mabl CLI to start an import session with the following command:
mabl tests import --name "My imported test"
You will be prompted to configure your test to use
localhost:8889 as a Selenium proxy and then run your test. In most cases the import will be automatically stopped when the Selenium test has completed, but if this event is not properly detected you can end the import at any time by pressing CTRL+C.
When the import session ends, you will have the opportunity to:
- View the descriptions of the imported steps
- Run the test locally
- Save the test
- Discard the test and exit
You can import multiple tests at once by using the
--multi flag with the import command:
mabl tests import --name "My imported test" --multi
When importing multiple tests, the mabl Selenium migration tool will automatically determine when one test run ends and another one starts. All imported tests will have the same name in mabl with a number appended at the end.
The migration tool is designed to be language and framework agnostics. As with every design, there are some limitations to consider. Currently, the tool can import the following Selenium actions as mabl test steps:
- Setting the viewport size
- Navigation to URLs
- Clicking elements on the page
- Entering text into fields
- Sending keypress events
After the initial import, you will need to update the mabl tests for some of the following:
- Assertions for various validations
- Using variables
- File download and upload actions
- Drag and drop actions
- Conditional and loop logic
- Hover actions
Should you have questions or need assistance with migrating Selenium tests to mabl, please contact mabl support via in-app chat or at [email protected]
Updated 2 months ago
|mabl CLI overview|