Expected 1 argument, got 0

I want to go through my dropdown menu and check if the correct page is opened.
Here is what have I done so far and faced the Keyword ‘Functions.Check if user is navigated to the corresponding category page’ expected 1 argument, got 0.


Someone I need help.(p.s newbie with Robot :slight_smile: )

Show the code where you call Check if user is navigated to the corresponding category page. You probably did not pass a list variable to the argument ${Dropdown_menu_options}.


I am doing this way.

No sure ,what is best approach to automate the testing of a dropdown menu with multiple options, where each option navigates to a corresponding page?
Is my start good actual with this approach ?

Well, you did not show the calling of Check if user is navigated to the corresponding category, bu I do see your calling of Validate the [Category] is displayed if the dropdown index is [2].
This is calling an embedded arguments keyword. Originally, maybe before Robot Framework 6, it was only possible to use embedded arguments or positional/named arguments, but not simultaneously.

You should see the documentation: Robot Framework User Guide (the whole chapter :slight_smile: ).

Embedded arguments is not a good strategy when passing lists. But possible.

In your case you could have:

*** Keywords ***
Validate the [${Category}] is displayed if the dropdown index is [${index}]
    Should Be True    "${Category}"    "${my_list_of_categories[${index}]}"
2 Likes

Hi Viki,

There’s a couple of syntax issues I see, so let’s deal with them first:

  1. You for is iterating over a scalar:
     
    You didn’t show what the contents of ${Dropdown_menu_options} looks like? So I’ll guess it’s a list something like ['page1', 'page2', 'page3']
     
    When you do this:

    FOR    ${option}    IN    ${Dropdown_menu_options} 
    

    On the first iteration ${option} is ['page1', 'page2', 'page3'], and then on the second iteration it’s nothing so that’s the end of the loop, I’m guessing that’s not what you want?
     
    So try this:

    FOR    ${option}    IN    @{Dropdown_menu_options} 
    

    Notice ${Dropdown_menu_options} changes to @{Dropdown_menu_options}, this tells RF that it’s a lit of things to iterate the FOR loop over
     
    See Simple FOR loop for more details

  2. [Arguments] after Set Variable:
     
    I’ve never seen this syntax before and it’s not mentioned in the documentation for Set Variable
     
    So unless your intention is for ${baseurl} to become something like [Arguments] page1 I don’t thinks this is what you want?
     
    I’ll also note that a resulting xpath of xpath://a[@herf='[Arguments] page1'] likely won’t work, so I’m reasonably sure this isn’t what you wanted.
     
    You could try:

        ${baseURL}    Set Variable    ${option}
    

     
    But I suspect your xpath’s still won’t find a match, but it’s not clear from what you’ve provided what you want there, probably something like:

        ${baseURL}    Set Variable    /apppath/${option}
    
  3. RETURN as the last line of the FOR loop:
     
    Having the RETURN here means it will always exit after the first iteration of the for loop, if this is not what you want, simply remove this line

Hopefully, this will help you get you closer to what you want,

Dave.

4 Likes