This project provides a custom annotation @FindByDataTestId
to locate elements by their data-testid
attribute using Selenium.
- Custom annotation
@FindByDataTestId
for locating elements. - Support for modern Java and Spring Boot versions.
- Easily integrable with existing Selenium tests.
- Locator factory to streamline the usage of the annotation.
- Java 17 or higher
- Maven 3.6.0 or higher
- Selenium WebDriver 4.9.0 or higher
- Spring Boot 3.1.0 or higher
git clone https://github.com/WEG-Technology/find-by-data-test-id.git
cd find-by-data-test-id
<dependencies>
<dependency>
<groupId>com.enuygun</groupId>
<artifactId>findByDataTestID</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
dependencies {
implementation 'com.enuygun:findByDataTestID:1.1.0-SNAPSHOT'
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
import com.enuygun.annotations.FindByDataTestId;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import com.enuygun.locators.DataTestIdElementLocatorFactory;
public class HomePage {
private WebDriver driver;
@FindByDataTestId("login-button")
private WebElement loginButton;
public HomePage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(new DataTestIdElementLocatorFactory(driver), this);
}
public void clickLoginButton() {
loginButton.click();
}
}
This project is licensed under the MIT License - see the LICENSE file for details.
Ercan Kırbıyık |