SOAP UI Raghav Pal Notes
SOAP UI Raghav Pal Notes
SOAP UI Raghav Pal Notes
================================
1)
1. What is SoapUI
2. Why to use SoapUI
3. How to Download and Install SoapUI
4. Difference between SoapUI Open Source and Paid versions
What is SoapUI
------------------------
API Testing Tool
For manual and automation testing of SOAP and REST APIs
2)
Cross-platform tool
Built entirely over Java platform
uses Swing for GUI
Project Navigator
Request Editor
Response Editor
================================
3.
WSDL - http://webservices.oorsprong.org/webs...
======================================
4.
5.
Properties can be used as variables to store values that can be referred in testing
System - ${#System#PropertyName}
Env - ${#Env#PropertyName}
Global - ${#Global#PropertyName}
==============================
log.info ".....Hellow World..!!"
6.
Notes
//Project
testRunner.testCase.testSuite.project.getPropertyValue("Name")
testRunner.testCase.testSuite.project.setPropertyValue("Name","I am in Project")
//TestSuite
testRunner.testCase.testSuite.getPropertyValue("Name")
testRunner.testCase.testSuite.setPropertyValue("Name","I am in TestSuite")
//TestCase
testRunner.testCase.getPropertyValue("Name")
testRunner.testCase.setPropertyValue("Name","I am in TestCase")
//TestStep
testRunner.testCase.getTestStepByName("CountryCodes").getPropertyValue("Name")
testRunner.testCase.getTestStepByName("CountryCodes").setPropertyValue("Name","I am
in Test Step")
//Global
com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "Name")
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "Name","I am in Global
Prop" )
// Add Property
testRunner.testCase.testSuite.project.addProperty("DOB")
// Remove property
//Project
testRunner.testCase.testSuite.project.removeProperty("Name");
//TestSuite
testRunner.testCase.testSuite.removeProperty("Name")
testRunner.testCase.properties.each
{
key,value -
log.info (testRunner.testCase.getPropertyValue(key))
//log.info (key+" - "+value)
}
_______________________________________________________
=======================================================
//How to Get Property//
//Project
def projectProp = testRunner.testCase.testSuite.project.getPropertyValue("Name")
log.info("Project Property...: "+projectProp)
//TestSuite
def testSuiteProp = testRunner.testCase.testSuite.getPropertyValue("Name")
log.info("TestSuite Property...:"+testSuiteProp)
//TestCase
def testCaseProp = testRunner.testCase.getPropertyValue("Name")
log.info("Project Property...:"+testCaseProp)
//TestStep
def testStepProp =
testRunner.testCase.getTestStepByName("TestStepsProperty").getPropertyValue("Name")
log.info("TestStep Property...:"+testStepProp)
//Global
def globalProperty =
com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "Name")
log.info("Global Property...:"+globalProperty)
testRunner.testCase.testSuite.project.setPropertyValue("Name","I am in Project***")
testRunner.testCase.testSuite.setPropertyValue("Name","I am in TestSuite***")
testRunner.testCase.setPropertyValue("Name","I am in TestCase***")
testRunner.testCase.getTestStepByName("TestStepsProperty").setPropertyValue("Name",
"I am in TestSteps***")
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "Name","I am in
Global***")
//Remoing Property //
testRunner.testCase.testSuite.project.removeProperty("DOB")
//Looping through Properties.It will print all properties and their values, based
on levels. Below one is for TestSuite level.
testRunner.testCase.testSuite.properties.each
{
key,value ->
log.info(testRunner.testCase.testSuite.getPropertyValue(key))
log.info(key+" - "+value)
}
=======================================================
7.
1. How to send values from response of one api to request of another api
It is nothing but transferring properties.
__________________________________________________________
8.
References
https://en.wikipedia.org/wiki/Apache_...
https://www.soapui.org/apidocs/com/ev...
Code Snippets
=============
import java.io.*;
log.info (" Hello World ... ");
int a = 10 ;
int b = 20 ;
int c = a+b ;
log.info (" Result is : "+c) ;
/*
* This is
* multiline comment
*/
//log
//context
//testRunner
log.info testRunner.metaClass.methods*.name.unique().sort()
======================
class Hello{
def log;
def context;
def testRunner;
========================
testStep.run(testRunner, context)
context.Hello.sayHello("Raghav")
============================
project = testRunner.testCase.testSuite.project ;
tcase = project.testSuites["TestSuite3"].testCases["TestCase1"] ;
hello = tcase.getTestStepByName("Hello");
hello.run(testRunner, context)
context.Hello.sayHello("Raghav")
project = testRunner.testCase.testSuite.project ;
tcase = project.testSuites["TestSuite"].testCases["TestCaseName"] ;
hello = tcase.getTestStepByName("Hello");
log.info testRunner.metaClass.methods*.name.unique().sort()
hello.run(testRunner, context)
==============================================
9.
Useful TIPS
https://www.soapui.org/docs/functiona...
_______________________________________________________
10.
Useful TIPS
---------------
How to get list of all TCs in a test suite
Get TestCaseName - testRunner.testCase.name
Notes:
groovy code to run test case
=====================
def tCase = testRunner.testCase.testSuite.testCases["TestCaseName"]
runner = tCase.run(new com.eviware.soapui.support.types.StringToObjectMap(),
false);
_______________________________________________________
11.
Groovy script
-------------------
def suite = context.testCase.testSuite.project.testSuites["TestSuiteName"]
suite.run(null,false)
// null can be replaced with : new
com.eviware.soapui.support.types.StringToObjectMap()
log.info (" === "+suite.getName().toString()+" - Executed successfully")
_______________________________________________________
12.
groovy script
------------------
def
projectName=testRunner.getTestCase().getTestSuite().getProject().getWorkspace().get
ProjectByName("REST Project 1")
projectName.run(null,true)
//projectName.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
_______________________________________________________
13.
_______________________________________________________
14.
groovy code can be given at project load script to load setup and teardown scritps
from file
-----------------------------------------------------------------------------------
---------------------------------------
def su = new File("setup.txt").text
def td = new File("teardown.txt").text
project.getTestSuiteList().each { testSuite -
testSuite.getTestCaseList().each { testCase -
testCase.setSetupScript(su)
testCase.setTearDownScript(td)
}
}
_______________________________________________________
15.
expected vs actual
REST - https://restcountries.eu/
SOAP - http://webservices.oorsprong.org/webs...
_______________________________________________________
16.
Contains
XPath Match
XQuery Match
Compliance
JSON Path assertions
__________________________________________________________
17.
//check attachments
assert messageExchange.responseAttachments.length == 0
log.info (messageExchange.responseAttachments.length)
__________________________________________________________
18.
cd C:\Program Files\SmartBear\SoapUI-5.4.0\bin\
testrunner.bat -sTestSuite1 -cAssertions "C:\Users\Raghav Pal\OneDrive\Projects\
SoapUIProjects\REST-Project-1-soapui-project.xml"
References:
Jenkins download - https://jenkins.io/download/
cd C:\Program Files\SmartBear\SoapUI-5.4.0\bin\
testrunner.bat -sTestSuite1 -cAssertions "C:\Users\Raghav Pal\OneDrive\Projects\
SoapUIProjects\REST-Project-1-soapui-project.xml"
__________________________________________________________
19.
Step 1 : Open SoapUI - Right click on Project and Select - Monitor APIs
References :
https://smartbear.com/lp/alertsite/fr...
20.
References:
https://git-scm.com/download
https://help.github.com/articles/sett...
_______________________________________________________
rapidapi.com
https://developers.pinterest.com/apps/
https://rapidapi.com/
Paresh
pareshsonparote
[email protected]/