Search This Blog

Showing posts with label Xpath. Show all posts
Showing posts with label Xpath. Show all posts

Monday, November 17, 2014

Assertions in SoapUI

Assertions in SoapUI are only applicable to test requests under test steps.We put assertions to understand the behavior of tests.Tests generally passes or fails depending upon the test(having assertion point) that we have defined.Assertions are of many types in SoapUI. I'll be discussing few common assertions here.
SoapUI has the below list of assertions:
  • Property Content
    • Contains
    • Not Contains
    • Xpath Match
    • XQuery Match
  • Compliance,Status and Standards
    • Invalid HTTP Status Codes
    • Schema Compliance
    • Valid HTTP Status Codes

Contains

This assertion ensures that the parsed string is a substring of the response token received.Below is the sample response on which most of the assertions will be discussed.

 <Response xmlns="http://localhost/rest-assured-example/service/single-user">  
   <email>test@hascode.com</email>  
   <firstName>Tim</firstName>  
   <id>1</id>  
   <lastName>Testerman</lastName>  
 </Response>  

Contains assertion takes 2 types of input:
  • String
  • Regex Pattern
String be defined below:














Contains assertion with RegEx:



Not Contains

This too used in the same way we used Contains assertion.

Xpath Match

User needs to define namespace in order to form an xpath.Namespace is nothing but the reference to the parent node.

Xquery Match

Xquery match is applicable to only xml responses.Its as similar as Xpath.Find the sample assertion below:





















Hope it helps :)

Tuesday, September 16, 2014

Xpath Formation using preceding-sibling,following-sibling & descendant

'descendant' attribute is used to select the first element on a page always

 <ul>  
   <li> Buy</li>  
   <li> Buy using Credit Card</li>  
   <li> Buy using Debit Card</li>  
   <li> Buy using Cash On Delivery </li>  
 </ul>  
  • Select the very first `li`
     /descendant::li[contains(text(),'Buy')][1]  
    
  • Select the preceding Sibling of the a node
  •  /descendant::li[contains(text(),'Buy')][2]/preceding-sibling::li  
    
    Selection
     <li> Buy</li>  
    
  • Select the following Sibling of a node
  •   /descendant::li[contains(text(),'Buy')][3]/following-sibling::li  
    
    Selection
     <li> Buy using Cash On Delivery </li>