Forum Discussion
You are almost correct..where as i am using only one jdbc connetion.. in that jdbc connetion only i will get list of table names.
Yes i am using groovy script to pick the random table names using the json nodes from thr jdbc response.
I used the code you provided.. but its picking only table.. though i have 10tables storing in custom variables
Thanks
so i suppose you groovy code will be like this:
def resp1=new XmlHolder(resp)
def respvalue =resp1.getNodeValue('/Results/ResultSet/Row[1]/*')
log.info respvalue
if (respvalue== null)
{
testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table1");
}
else
{
testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table1",respvalue)
}
def resp2=new XmlHolder(resp)
def respvalue =resp2.getNodeValue('/Results/ResultSet/Row[2]/*')
log.info respvalue
if (respvalue== null)
{
testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table2");
}
else
{
testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table2",respvalue)
}
def resp3=new XmlHolder(resp)
def respvalue =resp3.getNodeValue('/Results/ResultSet/Row[3]/*')
log.info respvalue
if (respvalue== null)
{
testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table3");
}
else
{
testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table3",respvalue)
}
and so on am i correct,
if this is the case then you can write my code and every else condition you can write
sBuild.append("\${#TestCase#Table1},")
this will solve you isue.
- HimanshuTayal4 years agoCommunity Hero
doubtsreadyapi You can try like this
sBuild.append("\"\${#TestCase#Table1}\"")
hope it will work. 🙂
- doubtsreadyapi4 years agoContributorHi Himanshu
Yes my groovy code is same what u have posted.
You mean to say i have to use below code in my groovy script? And change the table name accordingly?
StringBuilder sBuild = new StringBuilder();
if (respvalue== null)
{
testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table1");
}
else
{
testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table1",respvalue)
// Do this in where ever you are storing value
sBuild.append("\${#TestCase#Table1},")
}
//at the end of the script write this line
String str = sBuild.toString()
//to remove last , from string
str = str.substring(0, str.length() - 1)
testRunner.testCase.setPropertyValue("data_to_use",str);
I tried using ur code but i was getting compilation errors saying sbuild is already used, so i changed for ever table as sbuild1, sbuild2 and so on,
But still it was picking only one table
Please let me know if i am doing anything wrong
And at the end of the script also u want me to write for each table? And change data_for_use also for each table? - HimanshuTayal4 years agoCommunity Hero
doubtsreadyapi : Could should like below
StringBuilder sBuild = new StringBuilder(); if (respvalue== null) { testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table1"); } else { testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table1",respvalue) // Do this in where ever you are storing value sBuild.append("\${#TestCase#Table1},") } if (respvalue== null) { testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table2"); } else { testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table2",respvalue) // Do this in where ever you are storing value sBuild.append("\${#TestCase#Table2},") } if (respvalue== null) { testRunner.testCase.testSuite.testCases["Post_Dags"].removeProperty("Table3"); } else { testRunner.testCase.testSuite.testCases["Post_Dags"].setPropertyValue("Table3",respvalue) // Do this in where ever you are storing value sBuild.append("\${#TestCase#Table3},") } //and so on //at the end of the script write this line String str = sBuild.toString() //to remove last , from string str = str.substring(0, str.length() - 1) testRunner.testCase.setPropertyValue("data_to_use",str);
- doubtsreadyapi4 years agoContributor
Thanks for the detailed explanation, now the tables are coming with out null, where as the each table must come in quotes, like example, while sending the request the table list must be in below format.
"Table1",
"Table2",
"Table3",
"Table4"Where as now request its going as "Table1, Table2, Table3, Table4" Because of that still the backend jobs are failing.
is there a way where we can send the request in the below format.
"Table1",
"Table2",
"Table3",
"Table4"Thanks in Advance,
Thanks
- doubtsreadyapi4 years agoContributor
Related Content
- 4 years agoCapricornus