Data testing for multiple rows of table using Robot Framework

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.

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

hello @adskul,

I have never had such scenarios.

For the 1st scenario:

Are you using Excel ?

If so, have you tried the Excel lib ?

https://rpaframework.org/libraries/excel_files/

If not, you could use the Table lib :
https://rpaframework.org/libraries/tables/index.html

maybe using a loop :

For the 2nd (senario) I don’t understand, sorry.

What do you mean by dynamic ? Using CI/CD ?
You could try using Jenkins (if you can / are allowed to) and use it to make the Jenkins task run your program daily or every hour or something.

Thoses are ideas, because I have like I mentionned before, I never had such scenarios to automate.

Best,
TextSolver34761

Hi Adi,

If I understood your question, it sound like you’re on the right path, you just need a FOR loop

I think what you are after is something like this:

${rows1}=   get element count   xpath=//*[@id="MonthlyReport"]/tbody/tr
sleep    2
log to console   Total Rows= ${rows1}

FOR    ${rowno}    IN RANGE    ${rows1}
    ${ProductID}    Get Text    xpath=//*[@id="MonthlyReport"]/tbody/tr[${rowno}]/td[1]
    log to console    CBID is ${ProductID} 
    
    ${Status}=    Get Text    xpath=//*[@id="MonthlyReport"]/tbody/tr[${rowno}]/td[9]
    Log to Console    The ${ProductID} is with ${Status}
    ${Remarks}=    Get Text    xpath=//*[@id="tableChargebacks"]/tbody/tr[${rowno}]/td[10]
    Log to Console    The ${ProductID} is with ${Remarks}   
END

Click Element    xpath=//*[@id="Process"]

Dave.

1 Like

Thanks for your response but it is not working. With above code it is just checking first product ID and returning its details but not moving into loop to check other product IDs one by one and returning their details.
It should go to every row one by one. Log to console details for every row with Product ID, Status and Remarks. Then finally move for further action of process.

Hi Adi,

It should iterate every row unless one of the later steps in the loop fail on the first iteration or you forgot to change ${rows1} to ${rowno} inside the loop.

Can you show the result you got to confirm what went wrong?

Dave.

1 Like

The statement here:

log to console Total Rows= ${rows1}

Could you share what you have returned to the console? as the FOR will loop a range from 0 to end row

Thanks

1 Like

Hi, I used this and working as expected.

  FOR    ${rowno}    IN RANGE    1    ${rows}+1

        ${status} =    Get Text    xpath=//*[@id="monthlyreprot"]/tbody/tr[${rowno}]/td[1]
        Log To Console     Status is ${status}
1 Like