Bob
Bob

Reputation: 21

Robot Framework - How to get text of an element that then use that text in another keyword

I have a test case where I register an account with a unique email address.

What I want to do is sign out and sign back into the account using the newly created email address. I have a keyword that gets the text of the email from the My account section

Get email address

${email}  get text  ${contact_email}
[Return]  ${email}

I then have another keyword that signs into the account.

Enter Newly Registrered Email

input text  ${signin_email}

What I want to be able to do is pass the email address that I have gotten from the 'get text' into that test case.

Has anyone any idea how this can be done?

Upvotes: 1

Views: 6239

Answers (1)

Psytho
Psytho

Reputation: 3384

Assign the value of ${email} you get from Get Email Address to a variable (f.e. ${new_email}) and use it as an argument for Enter Newly Registrered Email:

${new_email}=    Get Email Adress
Enter Newly Registrered Email   ${new_email}

You have to define Enter Newly Registrered Email so that it uses an argument:

Enter Newly Registrered Email
    [Arguments]    ${signing_email}
    input text  ${signing_email}

If you want to do it in different test case you have to make ${new_email} a suite variable:

Set Suite Variable    ${new_email}

Further readings:

Upvotes: 4

Related Questions