Unable to get the results from the table for search value

I have one application under test.
In this scenario, I’m storing data from a script into a CSV file.

On a webpage, there’s a data grid with over 20 rows.
I’m attempting to input values from CSV one by one individually into a search field,
and I’m receiving a single-row result because the Product ID is unique.
However, in the table, there are two columns named Owner and Issues. Despite using the provided code, I’m not getting any results.
Web table looks like below.

My requirement is to validate the values of Owner and Issue for searched Product ID.

#TableData
    ${rows} =  get element count   xpath=//*[@id="FinalSheet"]/tbody/tr
    sleep  2
    log to console   Total Rows ${rows}
    ${Prods}=     Read Csv File To List      ProductID.csv
    ${ProductID}=    Set Variable    ${Prods[0]}
  FOR    ${element}    IN    @{ProductID}
        Log To Console  Product ID is ${element}
    FOR    ${rowno}    IN RANGE    1    ${rows}
    Input Text    xpath=//input[@placeholder='Search ...']    ${element}[0]
    Log To Console  Product ID in internal loop is ${element}[0]
    sleep   5
   ${Owner} =   Get Text    xpath=//*[@id="FinalSheet"]/tbody/tr[${rowno}]/td[10]
    log to console   Search table shows owner of ${element} is ${Owner}

    ${Issues} =   Get Text    xpath=//*[@id="FinalSheet"]/tbody/tr[${rowno}]/td[11]
    log to console   Search table shows issue of ${element} is ${issue}

    Run Keyword And Ignore Error    Should Be Equal    ${Owner}  MANAGER
    Run Keyword And Ignore Error    Should Be Equal    ${Issues}  NO
END
END

Hi Adi,

You’ve said:

The problem is you’ve not said what you are getting? Without access to the application or some indication to what you are getting it’s nearly impossible for anyone to help you.

Some leading questions that may help you discover your issue:

  • did you get an error?
  • what did the error say?
  • what was the result of Run Keyword And Ignore Error Should Be Equal ${Owner} MANAGER?
    • It seems very strange to use Run Keyword And Ignore Error on a validation step, are you sure you want to do this?
  • You have 2 FOR loops, you evaluate ${rows} = get element count outside the outer one, but use it’s value to drive the inner one, are you sure the number of rows won’t change? From the robot code you showed it shouldn’t but from the screen shots you showed it should?

Hopefully the answers you give yourself to those questions will lead you to your solution,

Dave.

1 Like

Output with this code is running.

  1. Only first product id is getting entered twice
  2. Error is saying that xpath=//*[@id=“FinalSheet”]/tbody/tr[2]/td[10] is not found.

When getting the result for the value I checked the xpath and it is always for row 1 and above point 2 error means the code is going to 2nd row.

Main Requirement.
I need to find the values for Owner and Issues for the Product IDs which are available in CSV.

Hence

  1. I have added loop to get first value from csv then get the values of owner and issues and then mentioning that it should be equal to MANAGER and NO.
  2. Then same action should keep running till all the values from CSV finished.

As I suspected you have multiple issues, this one I already gave you the answer for.

Also as I suspected you are picking and choosing which parts of you code to show, but you are hiding sections that are relevant to the problem you are describing. I only know this because it’s not possible to get the error you mentioned above with the code you posted.

The questions I gave you in my previous post should lead you to the answers you need,

Dave.

No. This is the only code I am using and it is not working as I said.
Is there any issue in above code because it looks like loop is not working.?

Hi Adi,

The error you mentioned indicates you are at this screen (from your original post)

However based on the code you showed you should be at this screen:

And the xpath //*[@id=“FinalSheet”]/tbody/tr[2]/td[10] should give you the blank value from the last column of the row with ID A1

So as you can see the information you’re giving us doesn’t match the errors you are getting.

I will also mention that you should take care with your indenting, as it’s all over the place in the code in your original post and robot framework (like python) is sensitive to indenting. As an example these lines should not have the same indent level:

So that may also be contributing to your issues.

Dave.

Well, I think I am following indentation rule properly as I am following in my previous 32 scripts. OK. Can you suggest the correct code if I want ;
First value from CSV then enter it into search field then getting the row and I can validate the OWNER and ISSUES for the row. Same should be repeat till all the values from CSV are finished.
Thanks !

I am able to resolve the issue and its working fine.

1 Like