Cert2 : Ask user for input and use it in someway

Hi! Its me again.

There is somekind of mistake with my code but I cannot figure out exactly what it is. I try to ask web page address from a user and use the input to access web page. I watched the videos and examples and did the same way, but this throws me an error. Here is a snippet of my code.

*** Tasks ***
Order robots from RobotSpareBin Industries Inc
    Open the robot order website
    Ask user for CSV path
    Submit the form in FORLOOP
    Create ZIP package from PDF Files
    Close the Browser


*** Keywords ***
Open the robot order website
     Open Available Browser    ${URL}
     Wait Until Page Contains Element    css:.modal-content
     Click Button    OK

Ask user for CSV path
    Add heading    Insert URL for downloading CSV
    Add text input    URL for downloading CSV file    placeholder=Insert URL here
    ${result}=    Run dialog
    RETURN    ${result}

Download the CSV file
    [Arguments]    ${CSV_FILE_PATH}
    Download    ${CSV_FILE_PATH}=    Ask user for CSV path    overwrite=True

Submit the form in FORLOOP
    [Arguments]    ${result}
    ${List_of_orders}=    Read table from CSV    ${result}    header=True
    Close Workbook
    FOR    ${orders}    IN    @{List_of_orders}......

Error3

Could you see the error description? Maybe it says you are missing mandatory argument? Or is it something else?

Hi Raivo,
I forgot to add a log, sorry for that. Yes that’s right,
Keyword ‘Submit the form in FORLOOP’ expected 1 argument, got 0.

I did try to delete task “Submit the form in FORLOOP” from the list, but then it just doesnt do the loop and jumps to the next task.

Hi, then the issue is > you have defined your keyword with mandatory argument

Submit the form in FORLOOP
    [Arguments]    ${result}

But when you are calling keyword from Tasks you are not passing any arguments. So from tasks should be like

*** Tasks ***
Order ...
    Open site...
    Ask...
    Submit the form in FORLOOP   ${argument_to_keyword}

I did try that too, it says undefined variable.

Error3_b

Your Ask user for CSV path returns value that is not saved. So you could save your result to ${result} and then input it to Submit...

Thank you again for your help. Not sure if I understand, I’ll try.

Maybe it will help :

https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-arguments

Hi,
yes i read that through, thank you. I used this guide .

This is what I came up with, doesnt throw an error in code but there’s a error in log, saying

OSError: [Errno 22] Invalid argument: “{‘URL for downloading CSV file’: ‘https://robotsparebinindustries.com/orders.csv’, ‘submit’: ‘Submit’}”

I guess there is still something wrong with my logic.

*** Tasks ***
Order robots from RobotSpareBin Industries Inc
    Open the robot order website
    ${CSV_FILE_PATH}=    Ask user for CSV path
    Submit the form in FORLOOP    ${CSV_FILE_PATH}

*** Keywords ***
Ask user for CSV path
    Add heading    Insert URL for downloading CSV
    Add text input    URL for downloading CSV file    placeholder=Insert URL here
    ${result}=    Run dialog
    RETURN    ${result}

Download the CSV file
    [Arguments]    ${CSV_FILE_PATH}
    Download    ${CSV_FILE_PATH}=    Ask user for CSV path    overwrite=True

Submit the form in FORLOOP
    [Arguments]    ${CSV_FILE_PATH}
    ${List_of_orders}=    Read table from CSV    ${CSV_FILE_PATH}    header=True

Did also try this besides many other options :slight_smile:

Order robots from RobotSpareBin Industries Inc
    Open the robot order website
    ${result}=    Ask user for CSV path
    Submit the form in FORLOOP    ${result}

Run dialog returns a result object with all input values . So if you want to return only url you need to access it in RETURN. There is example in documentation.

I got this to work by changing ${CSV_FILE_PATH} to ${CURDIR}${/}orders.csv
in Submit the form in FORLOOP

I also had troubles using Run dialog command for for creating user input, Get Value From User worked without any problems.