Forum Discussion

enthusiastictes's avatar
enthusiastictes
Occasional Contributor
13 years ago

How to Automate JDBC Step

Hi,

In my tests I have to log in to the DB & check for logging in DB for every Request/Response.
I query the DB based on a unique ID which I send in the SOAP Request.

I want to automate this step in SOAP UI now.
Right now in SOAP UI :
I've created a Test Suite in which the Test case has the following Test Steps :
1. Properties - which need to be passed to the SOAP Request
2. Groovy Script - which assigns Properties to the elements in the XML SOAP request based on XPath [Ex : holder("ns1://Txn ID)=TransactionID]
3. SOAP Request
4. Loop - which loops for 'n' number of iterations.

For each iteration, the Groovy script assigns the properties to the elements in the SOAP Request from the Properties step

for ex : Properties Step has the following Properties :
(TransactionID1=111
Amount1=120
Item1=Notebook
TransactionID2=222
Amount2=100
Item2=Pen)

Groovy Script Step has the following line which assigns Properties to the SOAP Script :

def TxnID = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("TransactionID"+context.loopIndex)
And each time the loopIndex will iterate :

For 1st iteration - Transaction ID1, Amount1 & Item1 are passed & for 2nd Iteration - Transaction ID2, Amount2 & Item2)

Now I want to add a JDBC Step after the SOAP Request step which automatically pulls the TransactionID automatically for every iteration.

My SQL query would look something like :
select * from table_name where transaction = " "
I want to pass TransactionID1(=111) in first iteration & in the 2nd iteration TransactionID2(=222)

Manually : for every iteration i am able to execute the following to get the results :
select * from table_name where transaction = $Properties#TransactionID1
and then have to change it to :
select * from table_name where transaction = $Properties#TransactionID2
I want to automate this step too.

Please advise,

Many Thanks
  • tjdurden's avatar
    tjdurden
    Frequent Contributor
    Do you need to create new properties, or could you not just update them after each iteration?

    Kind regards,
    Tim
  • enthusiastictes's avatar
    enthusiastictes
    Occasional Contributor
    HI Tim,

    I want to use the properties from the Properties step to execute the SQL


    what I mean to say is :
    My Properties step has two properties : TransactionID1=111 & TransactionID2=222

    My SQL query should automatically run each time (i.e for each iteration) like :
    select * from table_name where txnID = '111'
    select * from table_name where txnID = '222'
  • newMonk's avatar
    newMonk
    Occasional Contributor

    Hi,

     

    Did you get an answer to your question? If yes can you plz share your thoughts on it.

     

    Thanks.

  • newMonk's avatar
    newMonk
    Occasional Contributor

    Hope This Helps

     

    select * from table_name where txnID = ${NAME GIVEN TO THE PROPERTY STEP#ELEMENT NAME GIVEN IN THE PROPERTY STEP}

     

    select * from table_name where txnID = ${Property - Looper#txnID}