trying to increment a auxiliar counter but not working

755 views
Skip to first unread message

dnl 31337

unread,
Sep 11, 2015, 9:16:28 AM9/11/15
to robotframework-users
       
Hi all i have this part from my test, that i need  a second counter and i need to increment it when i have a 'fail' on the status from a keyword..

i try a lot kind of things to icrement but not success:

1 - I try to make another keyword just to increment.. didn't work because i try to set up the variable as a global variable but it won't change the value of the variable..

2 - I try to use different kind of keywords to increment, like evaluate  ${x+1}  or ${x}+1 nothing worked..

3 - I try to use on this code (down) like this: ${AUX+1} but get this error:

Resolving variable '${AUX+1}' failed: TypeError: coercing to Unicode: need string or buffer, int found


So i'm getting a little confuse with robotframework, because it's just a simple increment of variable (i++) that have in other programming languages..

How do i do???

thanks..


        ${tam}=               Get Matching Xpath Count    //*[@id='grid1']/tbody/tr[@class='odd' or @class='even']
        ${AUX}=               Set Variable    1
        
        :FOR    ${i}    IN RANGE    1    ${tam}+1
        \    Wait Until Page Contains Element              //*[@id='grid1']/tbody/tr[@class='odd' or @class='even']    20s
        \    ${elemento}=          Get Text                      //*[@id='grid1']/tbody/tr[${AUX}]/td[1]
        \    ${status}                 ${error}                       Run Keyword And Ignore Error          Should Contain     ${LISTA ATIVOS}    ${elemento}
        \    Run Keyword If       '${status}' == 'PASS'    Click Element                                  //*[@id='grid1']/tbody/tr[${AUX}]/td[4]/a[2]
        \    Run Keyword If       '${status}' == 'PASS'    Sleep                                              1s
        \    Run Keyword If       '${status}' == 'PASS'    Wait Until Page Contains Element     //*[@class="bootbox modal fade in"]/div[@class="modal-footer"]/a[contains(., "Sim")]    20s
        \    Run Keyword If       '${status}' == 'PASS'    Click Element                                  //*[@class="bootbox modal fade in"]/div[@class="modal-footer"]/a[contains(., "Sim")]
        \    Run Keyword If       '${status}' == 'PASS'    Wait Until Page Contains                  Operação realizada com sucesso.
        \    Run Keyword If       '${status}' == 'FAIL'      Convert To Integer                            ${AUX}
        \    ${AUX}=                 Set Variable If             '${status}' == 'FAIL'                           ${AUX}+1    ${AUX}     
        #\    Run Keyword If       '${status}' == 'FAIL'    Incrementar variavel
        #\    Exit For Loop If     '${status}' == 'FAIL'
        \    Sleep    2s

        Log To Console    aux: ${AUX}

The log out is giving 1+1 , and should return 2 .




      

Tatu Aalto

unread,
Sep 11, 2015, 11:02:52 AM9/11/15
to dnl 31337, robotframework-users

Ugh

Change:


${AUX}=               Set Variable    1

to
${AUX}=               Set Variable    ${1}

The 1 is, in Robot Framework, considered as a string. The ${1} is considered as number, int if recall correctly.

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Tatu Aalto

unread,
Sep 11, 2015, 11:05:55 AM9/11/15
to dnl 31337, robotframework-users

Ugh

And if the value does not change, then you must use the Evaluate[1] keyword.

-Tatu
Send from my mobile

[1] http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Evaluate

dnl 31337

unread,
Sep 11, 2015, 12:59:37 PM9/11/15
to robotframework-users, dnl3...@gmail.com
thanks bro...
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages