-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QAF Report should display description for locator instead of locator key #65
Comments
Hi, Could you please let me know if there is any workaround of this? |
Hi Nikhil, Below code snippet is a quick workaround for it.
package com.infostretch.steps;
import static com.qmetry.qaf.automation.core.ConfigurationManager.getBundle;
import java.util.Map;
import com.google.gson.Gson;
import com.qmetry.qaf.automation.step.QAFTestStepAdapter;
import com.qmetry.qaf.automation.step.StepExecutionTracker;
import com.qmetry.qaf.automation.step.TestStep;
import com.qmetry.qaf.automation.step.client.text.BDDDefinitionHelper.ParamType;
import com.qmetry.qaf.automation.util.StringUtil;
public class StepListener extends QAFTestStepAdapter {
@Override
public void afterExecute(StepExecutionTracker stepExecutionTracker) {
stepExecutionTracker.getStep().setDescription(processArgs(stepExecutionTracker.getStep()));
}
private String processArgs(TestStep step) {
Object[] actualArgs = step.getActualArgs();
String description = step.getDescription();
if (null == actualArgs || actualArgs.length <= 0)
return description;
for (int i = 0; i < actualArgs.length; i++) {
if ((actualArgs[i] instanceof String)) {
description = StringUtil.replace(description, String.valueOf(actualArgs[i]),
getParam((String) actualArgs[i]), 1);
}
}
return description;
}
private String getParam(String text) {
String result = getBundle().getSubstitutor().replace(text);
String value = String.valueOf(getBundle().getObject(result));
ParamType ptype = ParamType.getType(value);
if (ptype.equals(ParamType.MAP)) {
Map<String, Object> kv = new Gson().fromJson(value, Map.class);
if (kv.containsKey("desc")) {
value = String.valueOf(kv.get("desc"));
} else if (kv.containsKey("description")) {
value = String.valueOf(kv.get("description"));
}
return value;
}
return result;
}
}
qaf.listeners=com.infostretch.steps.StepListener |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For locator arguments in BDD scenario currently it display locator key in report, it should display locator description for more readability. Currently its like
If user has provided description for this key then it should be like
The text was updated successfully, but these errors were encountered: