2

I already written something like that:

Check privileges for PDTA
    ${end}=    Get Matching Xpath Count    //*[@id="listForm:displayDataTable:tbody"]/tr
    ${start}=    Set Variable    0
    : FOR    ${index}    IN RANGE    ${start}    ${end}
    \    ${status}=    Run Keyword And Ignore Error    Element Should Contain    listForm:displayDataTable:${index}    su    ${index}

And the log output is:

output.html

As you can see I want to get the number of row where I could find the value 'su'. This value can be found in a row number 6. Variable ${end} equals the number of all rows in the table.

Does anyone know how to get that number? Maybe there's a keyword which could help me, isn't it? Thanks in advance !!!

pingwin850
  • 299
  • 1
  • 7
  • 24

2 Answers2

3
: FOR    ${index}    IN RANGE    ${start}    ${end}
\    ${Name}=    Get Text    listForm:displayDataTable:${index}
\    ${IsEqual}=    Run Keyword And Return Status    Should Be Equal    ${Name}    Su
\    ${RowNumber}=    Set Variable    ${index}
\    Run Keyword If    '${IsEqual}'=='True'    Run Keywords    Log    Rownumber is ${RowNumber}    AND    Exit For Loop

U can try this.

The variable ${RowNumber} gets the row number which has the text "Su".

Rakesh
  • 1,525
  • 1
  • 15
  • 25
  • 1
    Will it only ever be one row? The above will cause problems if you're expecting multiples. But to deal with that just remove the exit of the for loop – shicky Jul 29 '16 at 12:32
  • Yes, it will always be one row. It is a unique value. I needed that row number to click a specific button. Ok, thanks for advice :) – pingwin850 Jul 29 '16 at 12:48
0

As part of your FOR loop, I would add:

Run Keyword If    '${status}' == 'PASS'    Log    ${index}

If you need to actually use it then simply set a variable or append to a list variable or something

shicky
  • 2,076
  • 5
  • 30
  • 44