Showing posts with label soapui. Show all posts
Showing posts with label soapui. Show all posts

Thursday, April 19, 2018

SOAP UI - Add Headers to all SOAP Ui Test Steps using Script

Add Headers to all SOAP Ui Test Steps using Script


import com.eviware.soapui.support.types.StringToStringMap 
 def headers = new StringToStringMap()
 headers.put("name","value");
 headers.put("name1","value1")
 headers.put("name2","value2")
 testRunner.testCase.testSteps.each
 {
  q->
  if(q.getValue().config.type.equals("restrequest") || q.getValue().config.type.equals("request"))
  {
   q.getValue().getHttpRequest().setRequestHeaders(headers)
  }
 }
 

Thursday, March 9, 2017

SOAPUI : Access Properties at different levels (Property Expansion)

Access Properties at different levels (Property Expansion)


Property Expansion(http://readyapi.smartbear.com/features/expansions/syntax) :

1) TestStep properties =  ${TestStepName#MyPropertyName}
2)Test case properties =${#TestCase#MyPropertyName}   -- Here TestCase is keyword
3)Project properties =   ${#Project#MyPropertyName}  --- Here Project  is keyword

Examples:
log.info context.expand('${#TestCase#endpoint3}')   // Groovy
or
Directly use : ${#TestCase#endpoint3}
In any Request


Using Properties values from a different testcase :


-----Working with current test case -----------
SET    :     testRunner.testCase.setPropertyValue("endpoint",endpoint)
GET :       log.info testRunner.testCase.getPropertyValue("endpoint")


----------------------------Working with some other test case -------------
get Value :
def project = testRunner.testCase.testSuite.project
log.info project.testSuites['TestSuite 1'].testCases['TC anme'].getTestStepByName("StepName").getPropertyValue("property_name")

Example :
def project = testRunner.testCase.testSuite.project
log.info project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].getTestStepByName("Count").getPropertyValue("authentication_PropertyFile")

Wednesday, March 8, 2017

SOAPUI : Extract xml response

Extract xml response


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
responseContent = testRunner.testCase.getTestStepByName("TestStepname").getPropertyValue("response")
//"response" is keyword

def holder = groovyUtils.getXmlHolder(responseContent)
log.info holder.getNodeValue("//locale/recordId")  // Here "locale/recordId" is like  //Parentnode/node

SOAP UI : Call Another Test Case using Groovy script

Call Another Test Case using Groovy script


RUN TEST CASE

def project = testRunner.testCase.testSuite.project
def runner = project.testSuites['Suite_name'].testCases['testCase_name'].run( null, true )
runner.waitUntilFinished()

example :
def project = testRunner.testCase.testSuite.project
def runner = project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].run( null, true )
runner.waitUntilFinished()

RUN TESTSTEP

def project = testRunner.testCase.testSuite.project
testRunner.runTestStep( project.testSuites['TestSuite1'].testCases['TestCase2'].testSteps['GroovyScript'] )

example:
def project = testRunner.testCase.testSuite.project
testRunner.runTestStep( project.testSuites['TestSuite 1'].testCases['GenericKmauthtoken'].testSteps['initialization'] )





Ref : 
https://community.smartbear.com/t5/SoapUI-NG/Res-Calling-test-cases-and-test-steps/td-p/18186/page/2

Monday, January 9, 2017

SOAP UI: Dynamically Change the Reponse/method in the Test Step

Dynamically Change the Response/Method in the Test Step

To Dynamically change the  response / method in the Test step , user needs to replace the URL in the scratch pad itself with the variables .

In the below example , I'm grabbing the id value from properties file(counter) in the response.For that I have first modified the scratch pad Resource ,this gets reflected in the test step and can be used further.


SOAP UI : Property Transfer

Property Transfer


Property Transfer : Used to search values from any test step and transfer it to another step.
Note : widely used to transfer value from Request to Property step (Ref example below)

In the below example :
  1. Create_product (Rest Request) - Contains the id value of the product created.
  2. Property Transfer - Tries to grab the id from above step (select the file to be searched using drop down and use JSON path finder http://jsonpath.com/ to traverse to the required string.
  3. Click on play in the Property transfer to validate the result
  4.  Select the target file in the drop down below
  5. Again play to evaluate the same