Set Global Variable not working for me

robot framweork = 7.3.1

I tried to use a variable between my test sections with the kw Set Global Variable but it always return "the variable ${total_balance} is not found
PS : I got the same error when I use Set Test Variable or Set Suite Variable

My code :

*** Test Cases *** 
Verification des donnees
    [Tags]  TXRAY002

    GIVEN l'utilisateur est sur la page Dashboard

    WHEN il récupére la valeur "Total_Balance"

    THEN La valeur est égale a 350

*** Keywords ***

l'utilisateur est sur la page Dashboard
      Se connecter
      Page Product est visible

il récupére la valeur "Total_Balance"
    ${total_balance}  SeleniumLibrary.Get Text  locator=${xpath.productpage.total_balance}
    Set Global Variable  ${total_balance}  ${total_balance}
    Log  ${total_balance}
   
La valeur est égale a 350
    Should Be Equal  ${total_balance}  350

the error

I have modified you example, but it worked:

Language: French

*** Paramètres ***
Bibliothèque      SeleniumLibrary

*** Unités de test ***
Verification des donnees
    [Étiquette]    TXRAY002
    Étant donné l’utilisateur est sur la page Dashboard
    Lorsque il récupére la valeur “Total_Balance”
    Alors la valeur est égale a 350

*** Mots-clés ***
l’utilisateur est sur la page Dashboard
    Se connecter
    Page Product est visible

il récupére la valeur “Total_Balance”
    # ${input_total_balance}=    SeleniumLibrary.Get Text    locator=${xpath.productpage.total_balance}
    VAR    ${input_total_balance}    ${350}
    Set Global Variable    ${total_balance}    ${input_total_balance}
    Log    ${total_balance}

La valeur est égale a 350
    Should Be Equal As Numbers    ${total_balance}    350

Se connecter
    Open Browser    about:blank

Page Product est visible
    No Operation

In your case you were using the same name of the variable and that was probably the problem.

You could also define total_balance in a Variables section, like:

*** Variables ***
${total_balance}        ${EMPTY}
3 Likes