mardi 6 juin 2023

Different random strings of numbers for text fields in Robot Framework using a variable

I'm testing a web application using Robot Framework/Selenium. I need to input numerical values to several text fields on a page, and I'm wondering if there's a way I can use a variable to get different random values for each of the fields.

I'm already using this keyword as suite setup:

    Random Values
        ${RANDOM_VALUE} =    Generate Random String    3    [NUMBERS]100-200
        Set Global Variable    ${RANDOM_VALUE}

And then these in the test case:

    Input Text    ${TEXT_FIELD_1}    ${RANDOM_VALUE}
    Input Text    ${TEXT_FIELD_2}    ${RANDOM_VALUE}
    Input Text    ${TEXT_FIELD_3}    ${RANDOM_VALUE}

and it works, but it gives me the same string for each text field I call the ${RANDOM_VALUE} variable to. Is there some way to generate a different random string for every text field on the page by using the same variable for all of them?

I'm still a total newbie in the world of automated testing, and I'm not at all well-versed in Python... I have a feeling that the solution involves using Python in some way, but I have no idea how to actually do that. I've tried searching for the answer or tutorials or something to help me, but I haven't been able to figure it out. Maybe the answer is just so simple that nobody else is having the same problem?

Thank you!




Aucun commentaire:

Enregistrer un commentaire