Skip to main content
No Result Found

Use AI self-heal for your Selenium tests running on BrowserStack Automate TurboScale

Automatically recover failed Selenium tests on BrowserStack Automate TurboScale with AI.

BrowserStack’s self-healing feature for automated tests enables automatic recovery from locator changes or sub-optimal locator strategies during test execution. This feature enhances test suite robustness, reduces test flakiness, and improves reliability.

The self-heal feature is currently in beta and supports the Selenium framework and specified browsers. If you are facing any issues using the feature, contact us.

Enable self-healing

To enable the self-healing feature, set the selfHeal capability to true in your test configuration file.

The self healing feature is supported on the following browsers:

Platform Supported browsers
Desktop Chrome v92 and above
Firefox v72 and above
Edge v92 and above

If you use the BrowserStack SDK, add the following capabilities in your browserstack.yml file:

browserstack.yml
Copy icon Copy
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
platforms:
  - os: Windows
    browserName: Chrome
    browserVersion: latest
projectName: BrowserStack Self-Heal
sessionName: First Self-Heal Test
selfHeal: true

At least one successful execution is required with self-heal to register the correct element context.

When the selfHeal capability is set to true, BrowserStack utilizes a rule based algorithm to identify the locators. If this strategy fails, it uses an AI based algorithm to find the locators.

To leverage AI for self-healing, check out our documentation on how to activate AI preferences.

All your tests that are recovered by self-heal appear on the dashboard marked by the self-heal icon as shown in the following image:

Self-healed Session

You can view these self-healed locators in the Text Logs tab of your session masked by the self-heal icon

Self-healed Locator

You can filter the self-healed builds using the builds filter and selecting the Healed option under Self-Healing dropdown.

Build view filter

You can also filter your self-healed sessions using the sessions filter and selecting the Healed option under Self-Healing dropdown.

Session view filter

You can filter the Text Logs to only view the self-healed locators as shown in the following image:

The Text Log filter will only be available if selfHeal is enabled for your test session.

Text Log Filter

BrowserStack recommends you to replace the locators in your test script with self-healed locators to improve the stability of your tests.

How Self-heal works

The self-healing functionality for Selenium locators represents an advanced approach in test automation to mitigate volatility of inconsistent tests. It intelligently adjusts locators by consolidating attributes and context, promoting robustness and flexibility. During runtime, it continuously monitors the web page to detect changes in the Document Object Model (DOM).

Once an element is successfully located on the page, its DOM path is logged for future reference. If the same element subsequently cannot be found, the system analyzes the current page state and generates new locators for modified elements based on past references.

The self-healing feature automatically detects new locators that were changes by web elements and continues the test execution.

Self-heal advantages

Self-healing streamlines test automation processes, offering several key benefits:

Stable builds: BrowserStack’s self-healing feature is smart. It adjusts to changes and carries out tasks intelligently. It uses artificial intelligence and machine learning to make sure automated tests can handle variations in applications or environments smoothly. This means fewer errors in Continuous Integration (CI) pipelines and smoother developments overall.

Intelligent Test Automation: BrowserStack’s self-healing capability guarantees test stability and consistency, even when confronted with small alterations in the UI of the web application. With its AI-powered feature dynamically adapting to these changes, glitches that used to disrupt testing are handled effectively while ensuring reliability; thus delivering a stable outcome for your entire suite of tests quickly.

Streamlined Test Maintenance: Application interfaces frequently evolve, requiring constant updates to testing scripts. BrowserStack’s self-healing feature automatically adjusts scripts, reducing manual intervention, time, and resource usage.

Self-heal limitations

Although the self-heal feature is engineered to handle a broad spectrum of issues, it comes with it’s own set of limitations, such as:

Performance: Enabling self-heal may slightly impact test execution time due to additional checks and recovery mechanisms, but such a performance impact is typically minimal. Self-heal is intended to complement good test design and error handling practices, not replace them. It is crucial always to ensure well-designed tests with proper error handling in place while regularly reviewing for issues that could be masked by the self-heal function.

Non-recoverable errors: Self-heal cannot recover from specific errors, such as WebDriver initialization failures or system-level issues, which are classified as non-recoverable.

Test accuracy: Self-heal reduces test inconsistency but can mask genuine problems in your web application or scripts. Always review logs carefully to understand why tests require healing.

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