summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/elements/Field.java
blob: bf573dbe0d2c433b39e3fd16ef399fd1a40ca639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.mavlushechka.a1qa.elements;

import com.mavlushechka.a1qa.utils.LoggerUtils;
import com.mavlushechka.a1qa.utils.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class Field extends BaseElement {

    public Field(By locator, String name) {
        super(locator, name);
    }

    public void sendKeys(String keys) {
        sendKeys(keys, false);
    }

    public void sendKeys(String keys, boolean isSecret) {
        WebElement field = find();

        LoggerUtils.info("Entering \"" + (isSecret ? StringUtils.replaceByStars(keys) : keys) + "\" keys to the \"" + getName() + "\" field.");
        field.sendKeys(keys);
    }

    public String getValue() {
        return find().getAttribute("value");
    }

}