Self-healing library for Selenium Web-based tests
for Gradle projects:
repositories {
maven {
url "https://dl.bintray.com/epam/healenium"
}
mavenCentral()
}
dependencies {
compile group: 'com.epam.healenium', name: 'healenium-web', version: '3.0'
}
for Maven projects:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-epam-healenium</id>
<name>bintray</name>
<url>https://dl.bintray.com/epam/healenium</url>
</repository>
</repositories>
<dependency>
<groupId>com.epam.healenium</groupId>
<artifactId>healenium-web</artifactId>
<version>3.0</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
serverHost = localhost
serverPort = 7878
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% )
serverHost - ip or name where hlm-backend instance is installed
serverPort - port on which hlm-backend instance is installed (7878 by default)
To disable healing for some element you can use @DisableHealing annotation over the method where element is called
@DisableHealing
public void clickTestButton() {
testButton.click();
}
WebDriver delegate = new ChromeDriver();
//declare configs for sha
Config config = ConfigFactory.load("sha.properties");
//create sha driver
SelfHealingDriver driver = SelfHealingDriver.create(delegate, config);
WebDriver delegate = new ChromeDriver();
//create sha driver
SelfHealingDriver driver = SelfHealingDriver.create(delegate);
basePath = sha/healenium
reportPath = build/reports
screenshotPath = build/screenshots/
heal-enabled = true
recovery-tries - list of proposed healed locators
basePath - folder to store base locators path
Important! Do not delete data from the folder where files with new locators are stored. They are used to perform self-healing in next automation runs
reportPath - folder to save test report with healing information
screenshotPath - folder to save screenshots of healed elements
heal-enabled - you could enable or disable healing by setting true or false flag to this variable
basePath = sha/selenium
Also you could set configs via -D or System properties, for example to turn off healing for current test run:
-Dheal-enabled=false
From version 2.0.2 Healium supports either standart By/@FindBy or PageAwareBy/@PageAwareFindBy usage for healing.
In 2.0.1 and earlier healing will work only for elements that are declared using PageAwareBy/@PageAwareFindBy
By buttonBy = PageAwareBy.by("MainPage", By.id(testButtonId));
Then you can simply call findElement() method as usual
driver.findElement(buttonBy).click();
Or use the shorter form
driver.findElement(PageAwareBy.by("MainPage", By.id(testButtonId))).click();
@PageAwareFindBy(page="MainPage", findBy = @FindBy(id = "markup-generation-button"))
WebElement testButtonId;
or not declaring the page. In this case page name will be set by default with the class name in which the locator is declared.
@PageAwareFindBy(findBy = @FindBy(id = "markup-generation-button"))
WebElement testButtonId;