guzhenhua / healenium-web

Self-healing library for Selenium Web-based tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

healenium-web

Self-healing library for Selenium Web-based tests

Maven Central Build Status
@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.2.4'
}

for Maven projects:

<dependency>
	<groupId>com.epam.healenium</groupId>
	<artifactId>healenium-web</artifactId>
	<version>3.2.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
serverHost = localhost
serverPort = 7878
imitatePort = 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% )

serverHost - ip or name where hlm-backend instance is installed

serverPort - port on which hlm-backend instance is installed (7878 by default)

imitatePort - port on which imitate instance is installed (8000 by default)

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-report-gradle or hlm-report-mvn plugin to enable reporting

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

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

About

Self-healing library for Selenium Web-based tests

License:Apache License 2.0


Languages

Language:Java 88.9%Language:HTML 10.2%Language:JavaScript 0.8%Language:Shell 0.1%