Data testing for multiple rows of table using Robot Framework

44 Views Asked by At

Below is the web table under testing. Some time rows would be 5 OR some time 25 or more. Currently I am able to test for 1 or 2 rows with my script shown below. I want to make it dynamic so it could test all the rows and return proper result.

enter image description here

There are two scenarios which I need to autoamte. 1. I want to check every row one by one and get results till the last rowThen I need click on Process when it returns row with the value Good OR Excellent.

My Current code to Process 1 row

${rows1} =  get element count   xpath=//*[@id="MonthlyReport"]/tbody/tr
sleep  2
log to console   Total Rows= ${rows1}
${ProductID}    Get Text    xpath=//*[@id="MonthlyReport"]/tbody/tr[${rows1}]/td[1]
log to console  CBID is ${ProductID} 

${Status} =   Get Text    xpath=//*[@id="MonthlyReport"]/tbody/tr[${rows1}]/td[9]
Log to Console The ${ProductID} is with ${Status}
${Remarks} =   Get Text    xpath=//*[@id="tableChargebacks"]/tbody/tr[${rows1}]/td[10]
Log to Console The ${ProductID} is with ${Remarks}   
Click Element  xpath=//*[@id="Process"]

2. In another case I need to search all these products id by entering id in search field and then verify if searched productid is in table. Currently I am doing this but it not dynamic. I want to test through all the products and verify its returning the row of searched Product ID.

My Current code to search 1 row

${ProductID1}    Get Text    xpath=//*[@id="MonthlyReportSearch"]/tbody/tr[${rows1}]/td[1]
log to console  CBID is ${ProductID}
#Click on Search tab
Input Text  //input[@placeholder='Search ...']    ${ProductID}
sleep   5
Should Be Equal    ${ProductID}    ${ProductID1}
IF    ${ProductID} == ${ProductID1}
Log To Console    Search Result is correct.
END
1

There are 1 best solutions below

0
ADS KUL On

I tried this and working as expected.

FOR    ${rowno}    IN RANGE    1    ${rows}+1    
${Status} =    Get Text    xpath=//*[@id="monthlyreport"]/tbody/tr[${rowno}]/td[1]
Log To Console    Status is ${Status}