Forum Discussion

lively629's avatar
lively629
Visitor
5 years ago

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,

 

  • nmrao's avatar
    nmrao
    Champion Level 3

    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.

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