Skip to content

Rafal-Laskowski/Metalloid-WebElement-Name

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@Name annotation for WebElements and Controls

Maven Central

Maven dependency:

<!-- https://mvnrepository.com/artifact/com.github.metalloid-project/webdriver-utils -->
<dependency>
    <groupId>com.github.metalloid-project</groupId>
    <artifactId>metalloid-webelement-name</artifactId>
    <version>2.0</version>
</dependency>

This library allows you to annotate WebElements and Controls with @Name annotation which accepts String as an argument.

Examples:

WebElement

@Name(description = "This is a name of element")
@FindBy(id = "button")
WebElement element;

Control

@Name(description = "This is a name of control")
@FindBy(id = "button")
Button button;

There are two possible usages. As a standalone library or as a part of Metalloid Core

Standalone

In order to be able to access the @Name annotation, you need to store those, invoking the store(Object pageObject) method from NameStore.class Example:

public class PageObject {

    @Name(description = "This is a name of element")
    @FindBy(id = "button")
    WebElement element;

    @Name(description = "This is a name of control")
    @FindBy(id = "button")
    Button button;

    public PageObject() {
        NameStore.store(this);
    }
}

Then you can read the @Name like this:

public class PageObject {

    @Name(description = "This is a name of element")
    @FindBy(id = "button")
    WebElement element;

    @Name(description = "This is a name of control")
    @FindBy(id = "button")
    Button button;

    public PageObject() {
        NameStore.store(this);
        //read from WebElement
        System.out.println(NameStore.getDescription(element));
        //read from Control
        System.out.println(NameStore.getDescription(button));
    }
}

With Metalloid Core

Metalloid Core saves descriptions of WebElements/Controls with Metalloid.initialize(Object pageObject) method. To read the description just use NameStore.getDescription() and provide WebElement or Control as an argument

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages