Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.
How to capture extension tool response as a file or Variable to use in further test steps.
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