dataSource with Groovy

来源:互联网 发布:360全景效果图软件 编辑:程序博客网 时间:2024/06/05 18:01

1. New Datasource -> choose Groovy :


import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
import com.eviware.soapui.support.XmlHolder
def project_level= testRunner.testCase.testSuite.project
def tStep = project_level.testSuites['TestSuite'].testCases['GetUserListCases'].testSteps['GetUserList']
def testStepContext = new WsdlTestRunContext(tStep)


//get response
def response = testStepContext.expand('${GetUserList#response}') 
// Transfer to xml
def xml = new XmlHolder(response)
/*get the value of data-id
 <ul id="list-items" class="dropdown-menu" aria-labelledby="dropdownMenu-list">
   <li>
      <a href="#" data-id="d3f7ce5c-03d3-4169-aa37-03b967722435">Conversion_operation1</a>
   </li>
*/

def investIDs = xml.getNodeValues("//li/a/@data-id")
//count the size of the data-id
def counts = investIDs.size()
// the current Row of the datasource
def i =testRunner.testCase.testSteps["DataSource"].currentRow
// set the data-id to the parm investIDs one by one
if(i<counts)
 {
  result["investIDs"]= investIDs[i]
 }

0 0