Skip to content

Set Actions


Set

Description: This function is used to set the value.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 Set @value ⬅ Hardcoded Input
mobileObject 🟢 Set Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 Set %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Enter the value [<Data>] in the Field [<Object>]", input = InputType.YES)
public void Set() {
    if (elementEnabled()) {
        Element.clear();
        Element.sendKeys(Data);
        Report.updateTestLog(Action, "Entered Text '" + Data + "' on '"
                + ObjectName + "'", Status.DONE);
    } else {
        throw new ElementException(ExceptionType.Element_Not_Enabled, ObjectName);
    }
}

SetIfExists

Description: This function is used to set the value if the element exists.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 SetIfExists @value ⬅ Hardcoded Input
mobileObject 🟢 SetIfExists Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 SetIfExists %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Enter the value [<Data>] in the [<Object>] if it exists", input = InputType.YES)
public void SetIfExists() {
    if (Element != null) {
        Set();
    } else {
        Report.updateTestLog(Action, "Element [" + ObjectName + "] not Exists", Status.DONE);
    }
}

SetAndCheck

Description: This function is used to set the value and check the expected text matches with element value.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 SetAndCheck @value ⬅ Hardcoded Input
mobileObject 🟢 SetAndCheck Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 SetAndCheck %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Enter the value [<Data>] in the Field [<Object>] and check [<Data>] matches with [<Object>] value", input = InputType.YES)
public void SetAndCheck() {
    if (elementEnabled()) {
        Element.clear();
        Element.sendKeys(Data);
        if (Element.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);
        }
    } else {
        throw new ElementException(ExceptionType.Element_Not_Enabled, ObjectName);
    }
}

setEncrypted

Description: This function is used to set an encrypted data to an element.

Input Format : @Expected encrypted text

ObjectName Action Input Condition Reference
mobileObject 🟢 setEncrypted @value ⬅ Hardcoded Input
mobileObject 🟢 setEncrypted Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 setEncrypted %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Enter the Decrypted value [<Data>] in the Field [<Object>]", input = InputType.YES)
public void setEncrypted() {
    if (Data != null && Data.matches(".* Enc")) {
        if (elementEnabled()) {
            try {
                Element.clear();
                Data = Data.substring(0, Data.lastIndexOf(" Enc"));
                byte[] valueDecoded = Encryption.getInstance().decrypt(Data).getBytes();
                Element.sendKeys(new String(valueDecoded));
                Report.updateTestLog(Action, "Entered Encrypted Text " + Data + " on " + ObjectName, Status.DONE);
            } catch (Exception ex) {
                Report.updateTestLog("setEncrypted", ex.getMessage(), Status.FAIL);
                Logger.getLogger(Basic.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            throw new ElementException(ExceptionType.Element_Not_Enabled, ObjectName);
        }
    } else {
        Report.updateTestLog(Action, "Data not encrypted '" + Data + "'", Status.DEBUG);
    }
}

setElementTimeOut

Description: This function is used to change default element finding wait time by input data in seconds

Input Format : @Expected data in seconds

ObjectName Action Input Condition Reference
Mobile 🟢 setElementTimeOut @value ⬅ Hardcoded Input
Mobile 🟢 setElementTimeOut Sheet:Column ⬅ Input from Datasheet
Mobile 🟢 setElementTimeOut %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.MOBILE, desc = "Change Default Element finding wait time by [<Data>] seconds",
        input = InputType.YES)
public void setElementTimeOut() {
    if (Data != null && Data.matches("[0-9]+")) {
        SystemDefaults.elementWaitTime = Duration.ofSeconds(Integer.valueOf(Data));
        Report.updateTestLog(Action, "Element Wait time changed to "
                + Data + " second/s", Status.DONE);
    } else {
        Report.updateTestLog(Action,
                "Couldn't change Element Wait time (invalid input) " + Data,
                Status.DEBUG);
    }

}

setInputByLabel

Description: This function is used to set the expected text to an input element that is adjacent to the provided label element.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 setInputByLabel @value ⬅ Hardcoded Input
mobileObject 🟢 setInputByLabel Sheet:Column ⬅ Input from Datasheet
mobileObject 🟢 setInputByLabel %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Set the data [<Data>] to an input element that is adjacent to the provided label element [<Object>]", input = InputType.YES)
public void setInputByLabel() {
    cc.Element = findInputElementByLabelTextByXpath();
    new Basic(cc).Set();
}

set_Relative

Description: This function will set given data from input column on element based on parent object

Input Format : @Expected Text

ObjectName Action Input Condition Reference
mobileObject 🟢 set_Relative @Data PageName << Hardcoded Input
mobileObject 🟢 set_Relative DatasheetName:ColumnName PageName << Input from Datasheet
mobileObject 🟢 set_Relative %variableName% PageName <<Input from variable
@Action(object = ObjectType.APP, desc = "Set [<Data>] on element based on parent [<Object>]", input = InputType.YES, condition = InputType.YES)
public void set_Relative() {
    doRelative(RelativeAction.SET);
}