Issue selecting a value from a variable using an argument

I wish to select a value in a variable based on the arguments in my test case. I believe I have a syntax or keyword error but I am unable to resolve. Does the error mean I am not using the correct syntax or does it mean I am not using the correct keyword? Let me know if more information is required in order to better assist. I am very new to auto testing so I am sure it could be a variety of issues.

Select Organization
[Arguments] ${org[0]}
click element //[@id=“mat-select-value-11”]
sleep 2s
mouse over //
[@id=“mat-option-33”]
sleep 2s
click element ${org[0]}

My desire in this case is that value A is selected. I assume if I used click element ${org[1]} then B is selected etc…

${ORGANIZATIONS}= A B C D E F

Error:
Element with locator ‘A B C D E F’ not found.

In practice this is the same as defining a variable named ${org[0]} so that is why you get all the elements when clicking.

You should use [Arguments] ${org}

1 Like

I tried but now I get a different error. I will place my entire test case to better show all the code.

*** Test Cases ***
Create a new Additional Cost
[Tags] Functional

Successfully access login page
Input valid Username or Password  ${USERNAME}  ${PASSWORD}
Select Profile Icon
Open Additional Cost
Click New Additional Cost
Select Organization

*** Keywords ***
Select Organization
[Arguments] ${org}
click element //[@id=“mat-select-value-11”]
sleep 2s
mouse over //
[@id=“mat-option-33”]
#//*[@id=“mat-option-61”]/span
sleep 2s
click element ${org}

This test case file references another data file with these values:

*** Variables ***
#Organizations

${ORGANIZATIONS}= A B C D E F

Error received:
Keyword ‘Select Organization’ expected 1 argument, got 0

Well, I did not mention a change on this line. It was correct :slight_smile:

1 Like