• Stars
    star
    163
  • Rank 226,522 (Top 5 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Self-healing library for Selenium Web-based tests

healenium-web

Self-healing library for Selenium Web-based tests

Maven Central @healenium
⇧ Join us! ⇧

How to start

0. Start hlm-backend by instruction

0.1 Add dependency

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>

1. Init driver instance of SelfHealingDriver

//declare delegate
WebDriver delegate = new ChromeDriver();
//create Self-healing driver
SelfHealingDriver driver = SelfHealingDriver.create(delegate);

2. Specify custom healing config file healenium.properties under test/resources directory, ex.:

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

3. Simply use standard By/@FindBy to locate your elements

@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;
    }
}

5. Add hlm-idea plugin to enable locator updates in your TAF code

6. Run tests as usual using Maven mvn clean test or Gradle ./gradlew clean test