SOAP UI Raghav Pal Notes

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 14

SOAP UI Raghav Pal

================================

1)

Today we will learn:

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

Why to use SoapUI


------------------------------
1. To create quick and efficient API tests
2. To create API functional, performance and security tests
3. To create API Testing automation framework

Step 1 : Download SoapUI from - https://www.soapui.org/downloads/late...

Step 2 : Install SoapUI


================================

2)

Today we will learn:

1. GUI components of SoapUI


2. Menu and Icons
3. Configurations

Cross-platform tool
Built entirely over Java platform
uses Swing for GUI

Project - Test Suite - Test Case - Test Step

Project Navigator
Request Editor
Response Editor

Sample REST URI - http://thomas-bayer.com/sqlrest/CUSTO...

================================

3.

Today we will learn:

1. How to create a SOAP API Project


2. How to add WSDL
3. How to create Test Suite - Test Cases
4. How to add Assertions
5. Run Test Step - Test Case - Test Suite
6. How to run in sequence and in parallel
7. How to create API Documentation

WSDL - http://webservices.oorsprong.org/webs...

======================================

4.

Today we will learn:

1. Create a REST Project


2. Add a REST request
3. How to add request parameters
4. Create a Test Case
5. Add assertions
6. Run and Validate

URI - Uniform Resource Identifier


REST Endpoints - https://restcountries.eu/

5.

oday we will learn:

1. What is property in soapui


2. Why do we use it
3. How to create properties at different levels
4. How to refer properties

Properties can be used as variables to store values that can be referred in testing

Properties can be accessed at following levels:

Project - ${#Project#PropertyName} ${#Project#PropertyName}


TestSuite - ${#TestSuite#PropertyName} $
{#TestSuite#countryName}
TestCase - ${#TestCase#PropertyName} $
{#TestCase#countryName}
TestStep - ${TestStepName#PropertyName} ` $
{#TestStepsProperty#countryName}

System - ${#System#PropertyName}
Env - ${#Env#PropertyName}
Global - ${#Global#PropertyName}

==============================
log.info ".....Hellow World..!!"

def ProjectPropertyname = context.expand('${#Project#Name}')


TestSuiteProperty = context.expand('${#TestSuite#Name}')
def TestCaseProperty = context.expand('${#TestCase#Name}')
def TestStepsProperty = context.expand('${TestStepsProperty#Name}')
def SystemProperty = context.expand('${#System#user.home}')
def EnvironmentProperty = context.expand('${#Env#JAVA_HOME}')
def GlobalProperty = context.expand('${#Global#Name}')

log.info("...Project Level Property Name is ==>"+ProjectPropertyname)


log.info("...TestSuite Level Property Name is ==>"+TestSuiteProperty)
log.info("...TestCase Level Property ame is ==>"+TestCaseProperty)
log.info("...TestSteps Level Property Name is ==>"+TestStepsProperty)
log.info("...System Level Property Name is ==>"+SystemProperty)
log.info("...Environment Level Property Name is ==>"+EnvironmentProperty)
log.info("...Global Level Property Name is ==>"+GlobalProperty)
==============================

6.

Today we will learn:

1. How to get property


2. How to set property
3. How to add property
4. How to remove property
5. How to loop through all properties

References, How to get Global Property


https://www.soapui.org/scripting-properties/tips-tricks.html

Notes

// Get and Set Property

//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")

// Loop through properties

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)

//How to Set Property//


//Here we have to give ("Key","Value")

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***")

//Getting Property Value directly as below


log.info(testRunner.testCase.testSuite.project.getPropertyValue("Name"))

//**Adding Property via Groovescript, Lets see**//


testRunner.testCase.testSuite.project.addProperty("DOB")

//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.

Today we will learn:

1. How to send values from response of one api to request of another api
It is nothing but transferring properties.

__________________________________________________________

8.

Today we will learn:


-----------------------------
1. What is Groovy
2. How to add groovy scripts in SoapUI
3. How to do basic coding in groovy in SoapUI
4. Basic Object Oriented Programming. (Classes and Objects)

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 a single line comment

/*
* This is
* multiline comment
*/

//log
//context
//testRunner

log.info testRunner.metaClass.methods*.name.unique().sort()

======================

class Hello{

def log;
def context;
def testRunner;

def Hello(log, context, testRunner){


this.log = log
this.context = context
this.testRunner = testRunner
}

def sayHello(String name){


log.info (" Hello "+name);
}

context.setProperty("Hello", new Hello(log,context,testRunner))

========================

def testStep = testRunner.testCase.getTestStepByName("Hello")

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()

context.setProperty("Hello", new Hello(log,context,testRunner))

def hello = testRunner.testCase.getTestStepByName("Hello");

hello.run(testRunner, context)

def ref = context.Hello;


ref.printHello("Raghav");

==============================================

9.

Today we will learn:

1. How to run a request or step from GUI


2. How to run a request or step from Groovy
3. Options for command line runs

Useful TIPS

//Groovy - run request from same TestCase


def status = testRunner.runTestStepByName("TestStepName")
def result = status.getStatus().toString();
log.info (" ---- "+result)

//Groovy - run request from another TestCase or TestSuite


project = testRunner.testCase.testSuite.project ;
tcase = project.testSuites["TestSuiteName"].testCases["TestCaseName"] ;
tstep = tcase.getTestStepByName("TestStepName");
def status = tstep.run(testRunner, context)
def result = status.getStatus().toString();
log.info (" ---- "+result)

https://www.soapui.org/docs/functiona...

_______________________________________________________
10.

Today we will learn:


-------------------------
1. How to run a Test Case from GUI
2. How to run a Test Case from Groovy
3. How to run a Test Case from CommandLine

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);

groovy code to loop test cases in a test suite


==================================
def testCases = context.testCase.testSuite.getTestCaseList()
testCases.each{
log.info(it.name)
}

command line run


==============
cd C:\Program Files\SmartBear\SoapUI-5.4.0\bin\
testrunner.bat -sTestSuite3 -cTestCase2 "C:\Users\Raghav Pal\OneDrive\Projects\
SoapUIProjects\CountryInfoService-soapui-project1.xml"

_______________________________________________________

11.

Today we will learn:


-------------------------
1. How to run a TestSuite from GUI
2. How to run a TestSuite from Groovy
3. How to run a TestSuite from CommandLine

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")

command line run


----------------------------
cd C:\Program Files\SmartBear\SoapUI-5.4.0\bin\
testrunner.bat -sTestSuite2 -j -f"C:\Users\Raghav Pal\Desktop" "C:\Users\Raghav
Pal\OneDrive\Projects\SoapUIProjects\CountryInfoService-soapui-project1.xml"

_______________________________________________________

12.

Today we will learn:


-------------------------
1. How to run a Project from GUI
2. How to run a Project from Groovy
3. How to run a Project from CommandLine

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)

command line run


--------------------------
cd C:\Program Files\SmartBear\SoapUI-5.4.0\bin\
testrunner.bat -j -f"C:\Users\Raghav Pal\Desktop" "C:\Users\Raghav Pal\OneDrive\
Projects\SoapUIProjects\CountryInfoService-soapui-project1.xml"

_______________________________________________________

13.

Today we will learn:


--------------------------
1. Different types of logs in SoapUI
2. How to view soapui general and error log files

_______________________________________________________

14.

Today we will learn:


--------------------------
1. What is SetUp and TearDown
2. Why to use it
3. How to use SetUp and TearDown scripts in SoapUI
4. How to set SetUp and TearDown with groovy scripts

Setup - runs before running the element in context


Teardown - runs after running the element in context

groovy code to set and get setup and teardown scripts


--------------------------------------------------------------------------
testRunner.testCase.testSuite.project.getTestSuiteByName('TestSuite1').getTestCaseB
yName('TestCase1').setSetupScript('log.info "setup"')
testRunner.testCase.testSuite.project.getTestSuiteByName('TestSuite1').getTestCaseB
yName('TestCase1').setTearDownScript('log.info "teardown"')

log.info (" -- "+testRunner.testCase.getSetupScript());


log.info (" -- "+testRunner.testCase.getTearDownScript());

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.

Today we will learn:

1. What are assertions


2. Why do we add assertions
3. Diff types of assertions in SoapUI

ASSERTIONS - validations on the response

expected vs actual

REST - https://restcountries.eu/
SOAP - http://webservices.oorsprong.org/webs...
_______________________________________________________

16.

Today we will learn

How to add different assertions in SoapUI

Contains
XPath Match
XQuery Match
Compliance
JSON Path assertions

SLA - SERVICE LEVEL AGREEMENT

JSON PATH FINDER - chrome-extension://bankcpekihijigplompggpdolehhnale/index.html

__________________________________________________________
17.

oday we will learn:

1. What is Script Assertion


2. How to add Script Assertion
3. Different assertion scripts for xml and json messages
4. Tips and Tricks

Script assertion works on the last reponse received in soapui


works with messageExchange object
(messageExchange object stores all the details of the last request and response)

Script Assertion samples


=====================

//check response time


assert messageExchange.timeTaken 4000

//check for Endpoint


log.info messageExchange.getEndpoint()

//check for TimeTaken


log.info messageExchange.getTimeTaken()

//check for header


log.info (messageExchange.responseHeaders["Content-Length"])
assert messageExchange.responseHeaders["Content-Length"] != null

//check attachments
assert messageExchange.responseAttachments.length == 0
log.info (messageExchange.responseAttachments.length)

//validate response nodes


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def requsetHolder = groovyUtils.getXmlHolder( messageExchange.requestContent )
def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContent )
def refNum = responseHolder.getNodeValue("//m:CountryCurrencyResult/m:sName")
assert responseHolder.getNodeValue("//m:CountryCurrencyResult/m:sName") == "Rupees"

//to get response


def resp = messageExchange.responseContentAsXml.toString()

For JSON response


-------------------------------

//get json response


import groovy.json.JsonSlurper
def responseMessage = messageExchange.response.responseContent
def json = new JsonSlurper().parseText(responseMessage)

//assert node values


log.info json.name
assert json.capital.toString() != null
assert json.name.toString() == "[Taiwan]"
testStepName = messageExchange.modelItem.testStep.name//to get the Test Step Name
log.info testStepName
xmlHold = messageExchange.responseContentAsXml.toString() //to store the response
as Xml string

__________________________________________________________

18.

Today we will learn:

1. How to get Jenkins


2. How to add SoapUI commands in Jenkins
3. How to run SoapUI tests from Jenkins

Step 1 : Open SoapUI and goto the test case

Step 2 : Right click and select Launch Test Runner

Step 3 : Run from Test Runner and copy the commands

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"

Step 4 : Get Jenkins on your system

Step 5 : Run jenkins - java -jar jenkins.war --httpPort=xxxx

Step 6 : Create a new job and add details

Step 7 : Run the job and validate results

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.

Today we will learn:


1. How to setup API Monitors
2. How to Monitor APIs in SoapUI

What is API Monitoring:


Checking of your APIs at regular interval for
Availability
Correctness
Performance

Step 1 : Open SoapUI - Right click on Project and Select - Monitor APIs

Step 2 : Connect to AlertSite (SignUp | SignIn)

Step 3 : Create Monitors

Step 4 : Add APIs to monitor and view in AlertSite

References :
https://smartbear.com/lp/alertsite/fr...

20.

Today we will learn:

1. Install git on windows


2. Create GitHub account
3. Add SoapUI Project on Git
4. Add, commit, push Changes
5. Remove project from Git

Step 1 : Download and Install Git

Step 2 : Create GitHub account

Step 3 : Add SoapUI Project to Git


Goto Command Prompt
Goto location of SoapUI Project
git init
git status
git add .
git commit -m "commit message"
git push -u url master

Step 4 : Validate changes are pushed to repository

Step 5 : Remove project from Git

References:
https://git-scm.com/download
https://help.github.com/articles/sett...

_______________________________________________________

rapidapi.com
https://developers.pinterest.com/apps/

Pinterest

create apps--------Name/Description myinterest/ timepass

app ID: 5049853009836687343


Secret: eedd3f936e9d7b6a03749bb5988ff7dde81465bd24fd5dd317f855e675297b3c

Redirect URIs: https://developers.pinterest.com/apps/5049853009836687343/

https://rapidapi.com/
Paresh
pareshsonparote
[email protected]/

You might also like