Unable to read variable file. I am getting error like Variable '${txt_huid}' not found. Did you mean: ${txt_userId} ${txt_proxy_huid} ${huid} ${stu_huid}

Unable to read variable file. I am getting error like Variable ‘${txt_huid}’ not found. Did you mean: ${txt_userId} ${txt_proxy_huid} ${huid} ${stu_huid}
Even though I can navigate from my resource file to variable library. If I explicitly mention xpath in the keyword then it works otherwise it throws this error.

For eg:
wait until keyword succeeds 20x 500ms click button id:addCenter
this way it works but if i use
wait until keyword succeeds 20x 500ms click button ${btn_centers}
it throws error like variable ${btn_centers} not found …do you mean:

Yesterday it was working . My google version is 111.0.5563.65 it was updated today then I updated my chromedriver as well. but it was failing before that as well

Hi Urvashi,

Try click button id:${btn_centers} and see if it works.

Hi Pramesh,

sure let me try.

Thanks

Variable ‘${btn_centers}’ not found. Did you mean:
${mnu_centers}

Suite Identification Of Dd Conflict | FAIL |
1 test, 0 passed, 1 failed

Variable ‘${btn_centers}’ not found. Did you mean:
${mnu_centers}

Suite Identification Of Dd Conflict | FAIL |
1 test, 0 passed, 1 failed

I got this error again @damies13 @Many Can you also help me in this?

Hi Urvashi,

There’s not really enough information to really understand what’s going on, the part of the error message you’re quoting seems to indicate you are trying to use a variable that doesn’t exist in your current scope (what I mean is a variable by that name might exist else where in your test but not in the location where you are trying to use it, see Variable priorities and scopes).

One common cause of this message is you simply mistyped the variable name (that’s why its giving you suggestions of other variables that do exist and have similar names)

Another common cause is you set a variable in a keyword, then after exiting the keyword try to use the variable outside the keyword (local variables don’t exists outside the keyword), if it’s this issue you can make the variable available outside the scope of the keyword using the builtin keywords for doing that.

If that doesn’t lead you to the answer, can you show the code of what you are trying to do where you are setting the variable as well as where you are trying to use it? (don’t forget to put your code in a code block starting and ending with ``` so your formatting doesn’t get messed up)

Dave.

Get Admin HUIDs
${cnt}  set variable    0
FOR    ${x}    IN RANGE    3
    wait until element is visible     ${mnu_access_mgmt}    20s
    click link    ${mnu_access_mgmt}
    wait until element is visible    ${mnu_centers}    20s
    click link    ${mnu_centers}
    wait until element is visible   ${btn_centers}    20s
    wait until keyword succeeds    20x    500ms    click button    ${btn_centers}

    ${center_names}    get from list    ${LIST_OF_CENTER}    ${cnt}
    input text    ${txt_abbreviation}   ${center_names}

txt_abbreviation = “xpath://input[@type=‘text’]”
txt_description = “xpath://input[@name=‘description’]”
chk_active = “id:active”
btn_save = “xpath://button[@id=‘saveBtn’]”
btn_centers = “id:addCenter”

*** Settings ***
Library SeleniumLibrary
Library DateTime
Variables …/Libraries/lib_menu_items.py
Variables …/Libraries/lib_center.py

In resource file I have already exported this

I am able to navigate from ${btn_centers} in resource file to the respective library named …/Libraries/lib_center.py. and variable is unique as well

Hi Urvashi,

It looks like you’ve given parts of the picture rather that the complete picture, but I’ll do my best to piece it together and try and work out what’s going on.

  1. is Get Admin HUIDs a keyword you are calling just before calling ${cnt} set variable 0? is it the keyword that the for statement belongs to? is it the test case name?

    • if Get Admin HUIDs is the keyword or test case name, then you have an indentation problem, that could be causeing you a context error, where you are in a different context than you expected
    • You FOR is missing it’s END, this is not related to your error and could be part of only showing part of the picture?
  2. the second post with txt_abbreviation = “xpath://input[@type=‘text’]”, is this the contents of lib_center.py?

    • is this the whole contents of lib_center.py or just an excerpt?
    • what about lib_menu_items.py?
    • importantly I’m guessing ${mnu_centers} and ${mnu_access_mgmt} come from lib_menu_items.py? what do they look like?
    • I’m guessing you didn’t include them because they are working for you? sometimes looking at what is working can give you a clue to why what’s not working isn’t.

From the limited information you’ve shown, I can only guess that there might be a syntax problem with the file lib_center.py which would cause robot framework to not import this file which would explain your errors, part of the reason I suspect this is only txt_abbreviation and btn_centers are shown in your test case (I guess the others come later?) and as txt_abbreviation comes after btn_centers, your test case fails before it reaches that. You didn’t mention which line triggered the error, but I’ll guess it’s wait until element is visible ${btn_centers} 20s.

From what you’ve shown the only think I can see that might be causing a syntax error in your python file is the double quite marks () not being the ones I’d expect in a python file, they should be the standard ascii double quotes ("), straight up and down not slanted. but this could be caused by not using the code block and the website re-rendering them with the wrong quote marks?

Based on what you’ve shown those are my best guesses, but then it could be something in the bit’s you didn’t show as well?

Dave.

Hi Dave,

There was a minor issue. In my lib_center.py file in the end I added one string by mistake , so there was error in this .py file .
It was like
${btn_centers}=“id:addcenter”
abc

Like this so because of ‘abc’ in the end of file messed everything this file became non-readable so none of the locator variables were accessible.
Thank you so much @damies13 and @Pramesh :slight_smile:

1 Like