LeanFT for Selenium Java SDK
LeanFT for Selenium Java SDK extends the Selenium WebDriver API with locators and utilities that enable creating tests that are more robust, and reduces Selenium test automation and maintenance efforts.
<dependency>
<groupId>com.microfocus.adm.leanft</groupId>
<artifactId>leanft-selenium-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
LeanFT's By class extends the original Selenium By class. To use it, import the following:
import com.hpe.leanft.selenium.By;
import com.hpe.leanft.selenium.ByEach;
import com.hpe.leanft.selenium.Utils;
The following example demonstrates locating elements by their visible text.
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.visibleText("Google Search"));
element.click();
driver.quit();
The following example demonstrates locating elements using a regular expression.
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.name(Pattern.compile("^btn")));
element.click();
driver.quit();
Locate an element using its HTML attributes and highlight it.
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
Map<String, String> attributes = new HashMap<>();
attributes.put("class", "gsfi lst-d-f");
attributes.put("id", "lst-ib");
WebElement element = driver.findElement(By.attributes(attributes));
element.click();
driver.quit();
LeanFT for Selenium API reference documentation can be found here
Finds elements based on their visible text.
Finds elements based on their visibility.
Finds elements based on their role.
Finds elements based on their type.
Finds elements based on their attributes (one or more). Attribute values can be defined using regular expressions.
Finds elements based on their computed style (one or more). Computed style values can be defined using regular expressions.
Finds elements based on the combination of locators (attributes, tags, styles etc.).
All the locators which accept a string as a value of the element's property were extended to support regular expressions, including the following Selenium native locators:
Returns a snapshot (image) of the selenium element as a Base64 string.
Highlights the selenium element in the browser.
To build the project, clone it and run the following command:
mvn clean install