Keva161
Keva161

Reputation: 2683

Passing a variable between two test cases?

I have a simple set of test cases in which I first assign a variable to a figure. Then in another test case, I am trying to access that variable and log in out.

Here's what I have so far.

TestCase1
    ${FIGURE}=  get text  xpath=//*[@id="reportTableId"]/tr[1]/td[14]
    set variable  ${FIGURE}
    log  ${FIGURE}

TestCase2
    log  ${FIGURE}

However, in the second test case. ${FIGURE} is showing as unassigned.

Is there a step that I am missing?

Upvotes: 0

Views: 93

Answers (1)

Pekka
Pekka

Reputation: 2270

Variables in test cases are local scope and not visible in other tests. If you want to access ${FIGURE} in another test, you should set it as suite variable:

TestCase1
    ${FIGURE}=  get text  xpath=//*[@id="reportTableId"]/tr[1]/td[14]
    set suite variable  ${FIGURE}
    log  ${FIGURE}

TestCase2
    log  ${FIGURE}

Upvotes: 2

Related Questions