cancel
Showing results for 
Search instead for 
Did you mean: 

Assertion of selective elements in a teststep

SOLVED
Highlighted
Contributor

Assertion of selective elements in a teststep

Hi,

I am using readyapi version 3.1.0 and I am trying to do the database testing using it
My test case looks like this

Iteration 1- csvdata file-Datasource step
step1
step2
step3
XPATH - [AC-1,EX-C-1]
XPATH - [AC-2,EX-C-2]
XPATH - [AC-3,EX-C-3]
step4
step5
step6
Datasource loop

Iteration 2- csvdata file-Datasource step
step1
step2
step3
XPATH - [AC-1,EX-C-4]
XPATH - [AC-2,EX-C-5]
XPATH - [AC-3,EX-C-6]
step4
step5
step6
Datasource loop


When i am looping my test case, all the steps are basically dbase calls only and output of step 3 is also from a table
and in the first iteration I am getting few fields & they are asserted using xpath assertion
But when i iterate it, input data for step3 changes and now I have 3 different fields in the same step(Step3) which i need to assert
It is like execution step3 is same, but it is displaying different output in the same column, because of my input data
And my requirement is, I need to assert all the elements using xpath match assertion
I am sure it can be achieved by Groovy script, wondering if in this flow I can be able to use readyapi existing components

Any help which leads to a direction is highly appreciated.

Please let me know, if it needs more clarification.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: Assertion of selective elements in a teststep

Thanks @nmrao for your suggestion

I have never used custom property earlier, however I am able to achieve it using script assertion and for now it seems that it running well with my huge data.

Still if i run into any scenario..will surely try the custom property approach.

 

Thanks for your help.

View solution in original post

17 REPLIES 17
Highlighted
Community Hero

Re: Assertion of selective elements in a teststep

Would you mind providing sample response of step 3(need not be same exact, but same structure of xml data) and what fields or data you need to verify as part of assertions.


Regards,
Rao.
Highlighted
Community Leader

Re: Assertion of selective elements in a teststep

@anand1  : I think doing this by groovy script will easy your work as this is so dynamic. Even if you want to assert via pre existing feature of ReadyAPI then please share some response of Step-3.


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



Thanks and Regards,
Himanshu Tayal
Highlighted
Contributor

Re: Assertion of selective elements in a teststep

Thanks @nmrao @HimanshuTayal 

Below is the screenshot for the call that I am executing, and in both the screenshot, call is made to the same table, however the expected value that I am trying to assert is changing.

 

Screen1:

Sc1.jpg

 

Screen2:

Sc2.jpg

 

Let me know if that helps.

 

Thanks,

Anand

Highlighted
Community Hero

Re: Assertion of selective elements in a teststep

Can't view the images, lost the quality on zooming.

Attach text of the response.


Regards,
Rao.
Highlighted
Contributor

Re: Assertion of selective elements in a teststep

Sure @nmrao 

Sc1.jpg

 

Sc2:

Sc2.jpg

 

And the response output is 

<Row rowNumber="1">
<_>[STUDENTOBJECTIVEASSESSMENTSCORErESULTS]</_>
<STUDENTOBJECTIVEASSESSMENTID>447023021</STUDENTOBJECTIVEASSESSMENTID>
<ASSESSMENTREPORTINGMETHODTYPEID>24</ASSESSMENTREPORTINGMETHODTYPEID>
<FORMATTEDRESULT>3611</FORMATTEDRESULT>
<SHORTDESCRIPTION>Scale score</SHORTDESCRIPTION>
<STUDENTOBJECTIVEASSESSMENTID>447023021</STUDENTOBJECTIVEASSESSMENTID>
<ASSESSMENTREPORTINGMETHODTYPEID>24</ASSESSMENTREPORTINGMETHODTYPEID>
<RESULT>3611</RESULT>
<RESULTDATATYPETYPEID>1</RESULTDATATYPETYPEID>
<EFFECTIVEFROMDATE>2020-03-11</EFFECTIVEFROMDATE>
<EFFECTIVETODATE/>
<CREATEDDATE>2020-03-11 09:05:58.353</CREATEDDATE>

 

Assertion is 

//Results[1]/ResultSet[1]/Row[1]/FORMATTEDRESULT[1]

#Reading for Information Scaled Score

 

Next Iteration 

<Row rowNumber="1">
<_>[STUDENTOBJECTIVEASSESSMENTSCORErESULTS]</_>
<STUDENTOBJECTIVEASSESSMENTID>447023021</STUDENTOBJECTIVEASSESSMENTID>
<ASSESSMENTREPORTINGMETHODTYPEID>24</ASSESSMENTREPORTINGMETHODTYPEID>
<FORMATTEDRESULT>3611</FORMATTEDRESULT>
<SHORTDESCRIPTION>Scale score</SHORTDESCRIPTION>
<STUDENTOBJECTIVEASSESSMENTID>447023021</STUDENTOBJECTIVEASSESSMENTID>
<ASSESSMENTREPORTINGMETHODTYPEID>24</ASSESSMENTREPORTINGMETHODTYPEID>
<RESULT>3611</RESULT>
<RESULTDATATYPETYPEID>1</RESULTDATATYPETYPEID>
<EFFECTIVEFROMDATE>2020-03-11</EFFECTIVEFROMDATE>
<EFFECTIVETODATE/>
<CREATEDDATE>2020-03-11 09:05:58.353</CREATEDDATE>
<LASTMODIFIEDDATE>2020-03-11 09:06:09.567</LASTMODIFIEDDATE>
<STUDENTOBJECTIVEASSESSMENTSCORERESULTBK/>
<ASSESSMENTREPORTINGMETHODTYPEID>24</ASSESSMENTREPORTINGMETHODTYPEID>
<CODEVALUE>Scale score</CODEVALUE>
<DESCRIPTION>Scale score</DESCRIPTION>
<EFFECTIVEFROMDATE>2012-07-01</EFFECTIVEFROMDATE>
<EFFECTIVETODATE/>
<CREATEDDATE>2012-08-01 00:00:00.0</CREATEDDATE>

 

Assertion is 

//Results[1]/ResultSet[1]/Row[1]/FORMATTEDRESULT[1]

#Functions (8, Alg I, Alg II) Scaled Score

 

Let me know it that helps

Highlighted
Community Hero

Re: Assertion of selective elements in a teststep

Not sure if it is copy paste issue. Both iteration 1, 2 responses look similar.
- "#Functions (8, Alg I, Alg II) Scaled Score" did not get what it is.

Few other questions
- how many rows in each iteration? fixed? varies?
- how does a data source row appears for each iteration, assuming that this data is used to verify response.


Regards,
Rao.
Highlighted
Contributor

Re: Assertion of selective elements in a teststep

No it is not a copy paste issue, my expected data is changing, however my actual landing data is being saved in the same column of the database

 

Few other questions
- how many rows in each iteration? fixed? varies?

[Anand] : If I understand it correctly, you are asking abt the response -if it is, then it is fixed
- how does a data source row appears for each iteration, assuming that this data is used to verify response.

[Anand] : Here is the caveat..the datasource row is changing based on type condition

for eg row 1 : is having 10 column data --( col1, col2, col3, ........col10)

          row2 : is having 10 columns data - but out of that 3 columns are different( col1, col2, col13,col14,col15 ..)

 

hope this helps

 

 

Highlighted
Community Hero

Re: Assertion of selective elements in a teststep

Thank you.
If the column data has expected data, can't that be used in XPath assertion?


Regards,
Rao.
Highlighted
Contributor

Re: Assertion of selective elements in a teststep

Yes..that is what i m using in my xpath assertion ...problem is 

Let me give u some more insight

 

Expected Data

R1- c1,c2,c3,c4,c5,c6

R2-c1,c2,c7,c8,c9,c10

 

Actual Data-Coming from my request

OR1- oc1,oc2,oc3,oc4,oc5,oc6

OR2- oc1,oc2,oc3,oc4,oc5,oc6

 

R- means row and c means columns and oc - output column,OR- output row

When i am running the loop

Xpath assertion : R1-OR1 -- True

Xpath assertion : R2-OR2 -- false

Reason is OR2 is giving me the output in the same columns, but my expected data which is changing based on some condition.

 

 

 

 

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Compete with community members in the TechCorner Challenge and get into the Leaderboard!

Rank Participant Points Earned
1 msiadak 12
2 nmrao 8
3 HimanshuTayal 3
Top Kudoed Authors