How to capture extension tool response as a file or Variable to use in further test steps.
Options
swapna0707
Posts: 41 ✭
package com.java;
import com.parasoft.api.Application;
import com.parasoft.api.ScriptingContext;
import java.io.IOException;
import java.util.ArrayList;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
//import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public Object login(Object input, ScriptingContext context) throws InterruptedException, IOException {
String fullString = "";
JSONObject finalObj = new JSONObject();
JSONObject obj = new JSONObject();
// Object[] jObj = new Object[10];
JSONArray jsonList = new JSONArray();
ArrayList<String> list = (ArrayList<String>) context.getValues("DS", "acc_data");
Application.showMessage("size:" + list.size());
for (int i = 0; i < list.size(); i++) {
String fullStringa = list.get(i);
// a = "<test>" + a + "</test>";
// fullString += a;
Application.showMessage("hi" + fullString);
String array1[] = fullStringa.split(",");
for (String temp : array1) {
if (temp.contains("id")) {
obj = new JSONObject();
obj.put("id", temp.substring(6, temp.length() - 1));
obj.put("access", Boolean.TRUE);
Application.showMessage(temp);
}
if (obj != null && !obj.isEmpty())
jsonList.add(obj);
}
finalObj.put("accessAllFutureAccounts","true");
finalObj.put("accounts", jsonList);
//jsonList.add(0, "accounts");
//jsonList.add(1, jsonList);
//context.setValue("final", finalObj.toJSONString());
Application.showMessage("jlist" + finalObj);
}
return finalObj;
}
}
Please help me on this.
Thanks,
Swapna
0
Comments
-
You could make your script return your JSON document as a string then chain a JSON Data Bank to your Extension Tool.
0