Self-healing library for Selenium Web-based tests
0. Start hlm-backend by instruction
for Gradle projects:
dependencies {
compile group: 'com.epam.healenium', name: 'healenium-web', version: '3.4.4'
}
for Maven projects:
<dependency>
<groupId>com.epam.healenium</groupId>
<artifactId>healenium-web</artifactId>
<version>3.4.4</version>
</dependency>
//declare delegate
WebDriver delegate = new ChromeDriver();
//create Self-healing driver
SelfHealingDriver driver = SelfHealingDriver.create(delegate);
recovery-tries = 1
score-cap = 0.5
heal-enabled = true
hlm.server.url = http://localhost:7878
hlm.imitator.url = http://localhost:8000
recovery-tries - list of proposed healed locators
heal-enabled - flag to enable or disable healing. Also you can set this value via -D or System properties, for example to turn off healing for current test run: -Dheal-enabled=false
score-cap - score value to enable healing with predefined probability of match (0.5 means that healing will be performed for new healed locators where probability of match with target one is >=50% )
hlm.server.url - ip:port or name where hlm-backend instance is installed
hlm.imitator.url - ip:port or name where imitate instance is installed
@FindBy(xpath = "//button[@type='submit']")
private WebElement testButton;
...
public void clickTestButton() {
driver.findElement(By.cssSelector(".test-button")).click();
}
4. To disable healing for some element you can use @DisableHealing annotation over the method where element is called. Ex: If you want to verify that element is not present on the page.
@DisableHealing
public boolean isButtonPresent() {
try {
return driver.findElement(By.cssSelector(".test-button")).isDisplayed();
} catch (NoSuchElementException e) {
return false;
}
}