cancel
Showing results for 
Search instead for 
Did you mean: 

why need to remove assertions before Adding Xpath match(which is put before request step)

Highlighted
Visitor

why need to remove assertions before Adding Xpath match(which is put before request step)

1.DataSource

2.Add xpath assertion

Notes:

def assertionList = myTestRequest.getAssertionList();
for( e in assertionList){
myTestRequest.removeAssertion(e);
}

if(contact_id!=""){
contact_idXPA = myTestRequest.addAssertion("XPath Match")
contact_idXPA.name="XPath_ContactId"
contact_idXPA.setPath(namespace1+contact_idX)
contact_idXPA.setExpectedContent(contact_id)
}

3.Request/Response

4.Loop_DataSource

If without the code marked as blue, the above asserion in step 2 is failed. while if adding  them back, the above asserion is failed,

 

5 REPLIES 5
Highlighted
Community Hero

Re: why need to remove assertions before Adding Xpath match(which is put before request step)

Abit of confusing.

 

1. Why asserton step without even calling the request?

2. Can't be using predefined assertion which is part of requestion step (without the existing step)?

 

If you have expected values varies for each row, then use custom propeties to have the row data saved and assert each test against custom property. This way, predefined assertion can be used instead of adding and removing each time.



Regards,
Rao.
Highlighted
Community Manager

Re: why need to remove assertions before Adding Xpath match(which is put before request step)

Great advice here nmrao.

 

@lively629 will the solution work for you?


Sonya Mihaljova
Community and Education Specialist
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Leader

Re: why need to remove assertions before Adding Xpath match(which is put before request step)

@lively629  : I think i got you correct, you are doing this to make generic according to your framework, ince i did this i place certain condition in my excel sheet and according to data i add or delete the assertions

 

If i am right  then what you can do is place blue code in Controller/Main Groovy script of your framework.

 

but if i am wrong then please elaborate more.

 


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Community Manager

Re: why need to remove assertions before Adding Xpath match(which is put before request step)

@lively629 any updates?


Sonya Mihaljova
Community and Education Specialist
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Moderator

Re: why need to remove assertions before Adding Xpath match(which is put before request step)

Hi @lively629,

 

We need more information here (as @nmrao requested).


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite
Top Kudoed Authors