Skip to content

ByLabel Actions


storeText

Description: This function is used store the element expected text into the runtime variable.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
APP 🟢 storeText @value ⬅ Hardcoded Input
APP 🟢 storeText Sheet:Column ⬅ Input from Datasheet
APP 🟢 storeText %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Store the [<Object>] element's text into the Runtime variable: [<Data>]", input = InputType.YES)
public void storeText() {
    if (elementPresent()) {
        String strObj = Input;
        if (strObj.startsWith("%") && strObj.endsWith("%")) {
            addVar(strObj, getElementText());
            Report.updateTestLog(Action, "Element text " + getElementText() + " is stored in variable " + strObj,
                    Status.PASS);
        } else {
            Report.updateTestLog(Action, "Invalid variable format", Status.DEBUG);
        }
    } else {
        throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
    }
}

storeTextinDataSheet

Description: This function is used to store the element's text into datasheet.

Input Format : @Expected datasheet name:column name

ObjectName Action Input Condition Reference
APP 🟢 storeTextinDataSheet Sheet:Column ⬅ Datasheet to where value is supposed br stored

Note: Ensure that your data sheet doesn't contain column names with spaces.

@Action(object = ObjectType.APP, desc = "Store the [<Object>] element's text into datasheet:columname [<Data>]", input = InputType.YES)
public void storeTextinDataSheet() {
    if (elementPresent()) {
        String strObj = Input;
        if (strObj.matches(".*:.*")) {
            try {
                System.out.println("Updating value in SubIteration " + userData.getSubIteration());
                String sheetName = strObj.split(":", 2)[0];
                String columnName = strObj.split(":", 2)[1];
                String elText = getElementText();
                userData.putData(sheetName, columnName, elText.trim());
                Report.updateTestLog(Action, "Element text [" + elText + "] is stored in " + strObj, Status.DONE);
            } catch (Exception ex) {
                Logger.getLogger(this.getClass().getName()).log(Level.OFF, ex.getMessage(), ex);
                Report.updateTestLog(Action, "Error Storing text in datasheet " + ex.getMessage(), Status.DEBUG);
            }

        } else {
            Report.updateTestLog(Action,
                    "Given input [" + Input + "] format is invalid. It should be [sheetName:ColumnName]",
                    Status.DEBUG);
        }
    } else {
        throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
    }
}

storeTextPresent

Description: This function is to store in variable true or false based on presence of text.

Input Format : @Expected element text

Condition Format: true or false

ObjectName Action Input Condition Reference
APP 🟢 storeTextPresent @value true or false ⬅ Hardcoded Input
APP 🟢 storeTextPresent Sheet:Column true or false ⬅ Input from Datasheet
APP 🟢 storeTextPresent %dynamicVar% true or false ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Store in variable true or false based on presence of text in [<Object>] element -> [<Data>]", input = InputType.YES, condition = InputType.YES)
public void storeTextPresent() {
    try {
        if (elementPresent()) {
            if (getElementText().contains(Data)) {
                addVar(Condition, "true");
            } else {
                addVar(Condition, "false");
            }
            Report.updateTestLog(Action, "Element presence flag has been stored into variable", Status.DONE);
        } else {
            throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
        }
    } catch (Exception ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.OFF, ex.getMessage(), ex);
        Report.updateTestLog(Action, ex.getMessage(), Status.FAIL);
    }
}

storeElementSelected

Description: This function is used store element selection state into runtime variable.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
APP 🟢 storeElementSelected @value ⬅ Hardcoded Input
APP 🟢 storeElementSelected Sheet:Column ⬅ Input from Datasheet
APP 🟢 storeElementSelected %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Store [<Object>] element  selection state into Runtime variable: -> [<Data>]", input = InputType.YES)
public void storeElementSelected() {
    if (elementPresent()) {
        String strObj = Input;
        if (strObj.startsWith("%") && strObj.endsWith("%")) {

            if (Element.isSelected()) {
                addVar(strObj, "true");
            } else {
                addVar(strObj, "false");
            }
            Report.updateTestLog(Action, "Element selected flag has been stored into variable '" + strObj + "'",
                    Status.DONE);
        } else {
            Report.updateTestLog(Action, "Variable format is not correct", Status.DEBUG);
        }
    } else {
        throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
    }
}

storeElementAttribute

Description: This function is used to store element's attribute into runtime variable.

Input Format : @Expected text

Condition Format: variable name

ObjectName Action Input Condition Reference
APP 🟢 storeElementAttribute @value ⬅ Hardcoded Input
APP 🟢 storeElementAttribute Sheet:Column ⬅ Input from Datasheet
APP 🟢 storeElementAttribute %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Store [<Object>] element's  attribute into Runtime variable ->  [<Data>]", input = InputType.YES, condition = InputType.YES)
public void storeElementAttribute() {
    if (elementPresent()) {
        addVar(Condition, Element.getAttribute(Data));
        Report.updateTestLog(Action, "Element's attribute value is stored in variable", Status.PASS);
    } else {
        throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
    }
}

storeElementValue

Description: This function is used store element's value into runtime variable.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
APP 🟢 storeElementValue @value ⬅ Hardcoded Input
APP 🟢 storeElementValue Sheet:Column ⬅ Input from Datasheet
APP 🟢 storeElementValue %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.APP, desc = "Store [<Object>] element's  value  into Runtime variable: -> [<Data>]", input = InputType.YES)
public void storeElementValue() {
    if (elementPresent()) {
        String strObj = Input;
        if (strObj.startsWith("%") && strObj.endsWith("%")) {
            addVar(strObj, Element.getAttribute("value"));
            Report.updateTestLog(Action,
                    "Element's value " + Element.getAttribute("value") + " is stored in variable '" + strObj + "'",
                    Status.DONE);
        } else {
            Report.updateTestLog(Action, "Variable format is not correct", Status.DEBUG);
        }
    } else {
        throw new ElementException(ExceptionType.Element_Not_Found, ObjectName);
    }
}

storeAlertPresent

Description: This function is used store exist or not exist based on the alert presence.

Input Format : @Expected Text

ObjectName Action Input Condition Reference
MOBILE 🟢 storeAlertPresent @value ⬅ Hardcoded Input
MOBILE 🟢 storeAlertPresent Sheet:Column ⬅ Input from Datasheet
MOBILE 🟢 storeAlertPresent %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.MOBILE, desc = "Store \"Exist\" or \"Not Exist\" based on the alert presence into -> [<Data>] Runtime variable", input = InputType.YES)
public void storeAlertPresent() {
    String strObj = Input;
    if (strObj.startsWith("%") && strObj.endsWith("%")) {
        if (isAlertPresent(mDriver)) {
            addVar(strObj, "Exist");
        } else {
            addVar(strObj, "Not Exist");
        }
        Report.updateTestLog(Action, "Alert Text Status Stored", Status.DONE);
    } else {
        Report.updateTestLog(Action, "Variable format is not correct", Status.DEBUG);
    }
}