Dynamic Object
setObjectProperty
Description: This function will set object property as data at runtime
Input Format : @Expected Text
| ObjectName | Action | Input | Condition | Reference | |
|---|---|---|---|---|---|
| Object | setObjectProperty |
@value | #var | PageName | |
| Object | setObjectProperty |
Sheet:Column | #var | PageName | |
| Object | setObjectProperty |
%dynamicVar% | #var | PageName |
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 = "Set object [<Object>] property as [<Data>] at runtime", input = InputType.YES, condition = InputType.YES)
public void setObjectProperty() {
if (!Data.isEmpty()) {
if (Condition.isEmpty()) {
String[] groups = Data.split(",");
for (String group : groups) {
String[] vals = group.split("=", 2);
setProperty(vals[0], vals[1]);
}
} else {
setProperty(Condition, Data);
}
String text = String.format("Setting Object Property for %s with %s for Object [%s - %s]",
Condition, Data, Reference, ObjectName);
Report.updateTestLog(Action, text, Status.DONE);
} else {
Report.updateTestLog(Action, "Input should not be empty", Status.FAILNS);
}
}
For standard usage:

For parameterized usage:

In the example above, part of the locator can be parameterized in the format #variableName. Note: This can also be done for all locators. In the test steps, use setObjectProperty. Input column will have the datasheet:column reference or variable reference from where to take the data. Condition column will have the parameterized part #variableName. Next test step would be a click or any other action on that object.
setglobalObjectProperty
Description: This function will set all objects property as data at runtime
Input Format : @Expected Text
| ObjectName | Action | Input | Condition | Reference | |
|---|---|---|---|---|---|
| Object | setglobalObjectProperty |
@value | #var | PageName | |
| Object | setglobalObjectProperty |
Sheet:Column | #var | PageName | |
| Object | setglobalObjectProperty |
%dynamicVar% | #var | PageName |
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.BROWSER, desc = "Set all objects property to [<Data>] at runtime.", input = InputType.YES, condition = InputType.YES)
public void setglobalObjectProperty() {
if (!Data.isEmpty()) {
if (Condition.isEmpty()) {
String[] groups = Data.split(",");
for (String group : groups) {
String[] vals = group.split("=", 2);
AutomationObject.globalDynamicValue.put(vals[0], vals[1]);
}
} else {
AutomationObject.globalDynamicValue.put(Condition, Data);
}
String text = String.format("Setting Global Object Property for %s with %s", Condition, Data);
Report.updateTestLog(Action, text, Status.DONE);
} else {
Report.updateTestLog(Action, "Input should not be empty", Status.FAILNS);
}
}