Skip to content

Text Input Actions


Fill

Description: This function is used to enter data in an input type object.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Object 🟢 Fill @value PageName ⬅ Hardcoded Input
Object 🟢 Fill Sheet:Column PageName ⬅ Input from Datasheet
Object 🟢 Fill %dynamicVar% PageName ⬅ Input from variable

Inputs in the Input column can be either hardcoded (in this case the data is preceded by a "@"), passed from the data sheet (datasheet name : column name) or passed from a variable value (%variable name%), as given in the above example.

@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the value [<Data>] in the Field [<Object>]", input = InputType.YES)
    public void Fill() {
    try {
            Locator.clear();
            Locator.fill(Data);
            Report.updateTestLog(Action, "Entered Text '" + Data + "' on '"
                    + "["+ObjectName+"]" + "'", Status.DONE);
        } catch(Exception e) {
            Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
            Report.updateTestLog("Could not perfom ["+Action+"] action", "Error: " + e.getMessage(),Status.FAIL);
        }
    }

FillIfDataExists

Description: This function is used to enter data in an input type object if data exists, else that step will be ignored.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Object 🟢 FillIfDataExists @value PageName ⬅ Hardcoded Input
Object 🟢 FillIfDataExists Sheet:Column PageName ⬅ Input from Datasheet
Object 🟢 FillIfDataExists %dynamicVar% PageName ⬅ Input from variable

Inputs in the Input column can be either hardcoded (in this case the data is preceded by a "@"), passed from the data sheet (datasheet name : column name) or passed from a variable value (%variable name%), as given in the above example.

@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the value [<Data>] in the [<Object>] if it Data exists", input = InputType.YES)
    public void FillIfDataExists() {
        Page.waitForLoadState();
        if (!Data.isEmpty()) {
            Fill();
        } else {
            Report.updateTestLog(Action, "Data not present", Status.DONE);
        }
    }

FillIfVisible

Description: This function will check if an element is visible. If the element is visible, data will be entered for that element else that step will be ignored.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Object 🟢 FillIfVisible @value PageName ⬅ Hardcoded Input
Object 🟢 FillIfVisible Sheet:Column PageName ⬅ Input from Datasheet
Object 🟢 FillIfVisible %dynamicVar% PageName ⬅ Input from variable

Inputs in the Input column can be either hardcoded (in this case the data is preceded by a "@"), passed from the data sheet (datasheet name : column name) or passed from a variable value (%variable name%), as given in the above example.

@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the value [<Data>] in the [<Object>] if visible", input = InputType.YES)
    public void FillIfVisible() {
        Page.waitForLoadState();
        if (Locator.isVisible()) {
            Fill();
        } else {
            Report.updateTestLog(Action, "[" + ObjectName + "]" + " is not visible", Status.DONE);
        }
    }

FillAndCheck

Description: This function is used to enter data in object and check if the element's value matches with the entered value.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Object 🟢 FillAndCheck @value PageName ⬅ Hardcoded Input
Object 🟢 FillAndCheck Sheet:Column PageName ⬅ Input from Datasheet
Object 🟢 FillAndCheck %dynamicVar% PageName ⬅ Input from variable
@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the value [<Data>] in the Field [<Object>] and check [<Data>] matches with [<Object>] value", input = InputType.YES)
    public void FillAndCheck() {
        try {
            Locator.clear();
            Locator.fill(Data);
            if (Locator.getAttribute("value").equals(Data)) {
                Report.updateTestLog("Set", "Entered Text '" + Data + "' on '"
                        + "["+ObjectName+"]" + "'", Status.DONE);
            } else {
                Report.updateTestLog("Set", "Unable Enter Text '" + Data
                        + "' on '" + ObjectName + "'", Status.FAIL);
            }
        } catch(Exception e) {
            Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
            Report.updateTestLog("Could not perfom ["+Action+"] action", "Error: " + e.getMessage(),Status.FAIL);
        }
    }

fillEncrypted

Description: This function is used to enter encrypted data to an object

Input Format : @Encrypted text

ObjectName Action Input Condition Reference
Object 🟢 fillEncrypted @value PageName ⬅ Hardcoded Input
Object 🟢 fillEncrypted Sheet:Column PageName ⬅ Input from Datasheet

Note: If the data is passed from a data sheet, the data in the datasheet should be encrypted. To manually encrypt a data, select the data cell, right click and select Encrypt

@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the Decrypted value [<Data>] in the Field [<Object>]", input = InputType.YES)
    public void fillEncrypted() {
        if (Data != null && Data.matches(".* Enc")) {
                try {
                    Locator.clear();
                    Data = Data.substring(0, Data.lastIndexOf(" Enc"));
                    byte[] valueDecoded = Encryption.getInstance().decrypt(Data).getBytes();
                    Locator.fill(new String(valueDecoded));
                    Report.updateTestLog(Action, "Entered Encrypted Text " + Data + " on " + "["+ObjectName+"]", Status.DONE);
                } catch (Exception ex) {
                    Report.updateTestLog(Action, ex.getMessage(), Status.FAIL);
                    Logger.getLogger(TextInput.class.getName()).log(Level.SEVERE, null, ex);
                }

        } else {
            Report.updateTestLog(Action, "Data not encrypted '" + Data + "'", Status.DEBUG);
        }
    }

PressSequentially

Description: This function is used to press keys sequentially in an input type object which is adjacent to the provided label type element.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
Object 🟢 PressSequentially @value PageName ⬅ Hardcoded Input
Object 🟢 PressSequentially Sheet:Column PageName ⬅ Input from Datasheet
Object 🟢 PressSequentially %dynamicVar% PageName ⬅ Input from variable
@Action(object = ObjectType.PLAYWRIGHT, desc = "Enter the value [<Data>] in the Field [<Object>]", input = InputType.YES)
    public void PressSequentially() {
        try {
            Locator.clear();
            Locator.pressSequentially(Data);
            Report.updateTestLog(Action, "Entered Text '" + Data + "' on '"
                    + "["+ObjectName+"]" + "'", Status.DONE);
        } catch(Exception e) {
            Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
            Report.updateTestLog("Could not perfom ["+Action+"] action", "Error: " + e.getMessage(),Status.FAIL);
        }
    }

Clear

Description: This function is used to clear an input field

ObjectName Action Input Condition Reference
Object 🟢 Clear PageName
@Action(object = ObjectType.PLAYWRIGHT, desc = "Clear text [<Data>] from object [<Object>].")
    public void Clear() {
        try {
            Locator.clear();
            Report.updateTestLog("Clear", "Cleared Text on '" + "["+ObjectName+"]" + "'", Status.DONE);
        } catch(Exception e) {
            Logger.getLogger(this.getClass().getName()).log(Level.OFF, null, e);
            Report.updateTestLog("Could not perfom ["+Action+"] action", "Error: " + e.getMessage(),Status.FAIL);
        }
    }