# Set Global Variable not working for me

**URL:** <https://forum.robotframework.org/t/set-global-variable-not-working-for-me/9069>\
**Category:** Libraries\
**Created:** [10 July 2025 13:54 UTC](https://forum.robotframework.org/t/set-global-variable-not-working-for-me/9069 "2025-07-10T13:54:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehdi](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mehdi/32/4050_2.png) [@Mehdi](https://forum.robotframework.org/u/Mehdi)\
**Post date:** [10 July 2025 13:54 UTC](https://forum.robotframework.org/t/set-global-variable-not-working-for-me/9069/1 "2025-07-10T13:54:00Z")

</div>

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 :

```python
***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

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/0/06a0a7f54bb70ce60f5b67f7f95b4cca8fadada1.png)

---

<div class="post-metadata">

**Author:** ![HelioGuilherme66](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/helioguilherme66/32/34_2.png) [@HelioGuilherme66](https://forum.robotframework.org/u/HelioGuilherme66)\
**Post date:** [10 July 2025 15:32 UTC](https://forum.robotframework.org/t/set-global-variable-not-working-for-me/9069/2 "2025-07-10T15:32:40Z")

</div>

> [@Mehdi](#):
>
> \*\*\* Test Cases \*\*\*  
> Verification des donnees  
> [Tags] TXRAY002
> 
> ```python
> 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

I have modified you example, but it worked:

```python
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:

```python
***Variables***
${total_balance} ${EMPTY}

```
