How to check the column is sorted or not

1,997 views
Skip to first unread message

Amit Dengale

unread,
Jun 17, 2013, 6:18:14 AM6/17/13
to robotframe...@googlegroups.com
Hi,

I have a table with 4 columns. I wanted to check if the 2nd column is alphabetically sorted or not?
Is there any keyword in robot to check this? If no can anyone please help me how to do it?

--
Thanks,
Amit

Kevin O.

unread,
Jun 17, 2013, 9:27:16 AM6/17/13
to robotframe...@googlegroups.com
Seems like there ought to be a keyword in Collections for that...
If you can get the columnar values into a list you can copy, sort, can compare it. Here's an example:

    @{actual}=    Create List    alpha    bravo    charlie
    @{sorted}=    Copy List    ${actual}
    Sort List    ${sorted}
    Lists Should Be Equal    ${actual}    ${sorted}
    @{actual}=    Create List    bravo    alpha    charlie
    @{sorted}=    Copy List    ${actual}
    Sort List    ${sorted}
    Run Keyword And Expect Error    Lists are different:*    Lists Should Be Equal    ${actual}    ${sorted}

Kevin

Amit Dengale

unread,
Jun 28, 2013, 2:17:32 AM6/28/13
to robotframe...@googlegroups.com

Amit Dengale <aden...@gmail.com>

Thanks for your reply Kevin. Sorry for the late reply.

Here my problem is that I am not getting the text values of all the rows in the list.

eg. this is how I get the individual text values 

Get Text    xpath=//*[@id="accountsTabPanel"]/*[@id="accountsTabPanel-body"]/div[contains(@id,"partnergrid-")]//table/tbody/tr[1]/td[2]

    Get Text    xpath=//*[@id="accountsTabPanel"]/*[@id="accountsTabPanel-body"]/div[contains(@id,"partnergrid-")]//table/tbody/tr[2]/td[2]

..

..

    Get Text    xpath=//*[@id="accountsTabPanel"]/*[@id="accountsTabPanel-body"]/div[contains(@id,"partnergrid-")]//table/tbody/tr[n]/td[2]

 

how should I get all the text values in the list?

https://mail.google.com/mail/u/0/images/cleardot.gif

 

Kevin Ormbrek

 

https://mail.google.com/mail/u/0/images/cleardot.gif

This method is slow and fills up the logs a bit, but is reasonable for small tables.

 

${cnt}=    Get Matching Xpath Count    //*[@id="accountsTabPanel"]/*[@id="accountsTabPanel-body"]/div[contains(@id,"partnergrid-")]//table/tbody/tr/td[2]

${values}=    Create List

:FOR    ${i}    IN RANGE    1    ${cnt} + 1

...    ${value}=    Get Text    xpath=(//*[@id="accountsTabPanel"]/*[@id="accountsTabPanel-body"]/div[contains(@id,"partnergrid-")]//table/tbody/tr/td[2])[${i}]

...    Append To List    ${values}    ${value}

https://mail.google.com/mail/u/0/images/cleardot.gif

Amit Dengale <aden...@gmail.com>

https://mail.google.com/mail/u/0/images/cleardot.gif

https://mail.google.com/mail/u/0/images/cleardot.gif

https://mail.google.com/mail/u/0/images/cleardot.gif

https://mail.google.com/mail/u/0/images/cleardot.gif

Thanks Kevin, It works like a charm.

I just changed (...) by (\) in the for loop.

I will update the post with this solution.

Reply all
Reply to author
Forward
0 new messages