How to get variables and use it into another test script

Dear Mates,

I’m new to using the robot framework, I have 2 test scripts here:

  • TC01 - CreateReservation.robot. – I create script for automating graphql (mutation)
  • TC02 - CheckReservation.robot – I crate script for automating databse

TC01 - CreateReservation.robot on this test case the result will be like this P${reservationId} = ['1071'] the value of 1071 will be generated if the reservation is done

My question what should I do to get the value of reservationId and I can use it on my TC02 - CheckReservation.robot

This is an example of my script:

…${reservationResponse} Set Variable ${response.json()}
${success}= Get Value From Json ${reservationResponse} $.data.createExperienceMerchantReservation.success
${reservationId}= Get Value From Json ${reservationResponse} $.data.createExperienceMerchantReservation.reservationId
Log to Console ${reservationId}
Log to Console ${success}

So my purpose is get the variable generated by TC01 - CreateReservation.robot
and validated via another script TC02 - CheckReservation.robot

There are several ways, but I would go for the use of file operations in OperatingSystem library.

Look for Append To File and Get File, for example.

Hi @rialdy,

There are many ways to pass the values, most of them involve files, the example @HelioGuilherme66 mentioned is the simplest of them.

If you have lots of values that you want to pass from one test to the next, or you are using multiple machines to run your tests and want to pass the value from one machine to another then Test Data Table might be useful. don’t be put off that the has been no updates, it’s simply no one has reported any bugs or requested a new feature and it has all the features I intended it to have.

Dave.

If the suites are always ran together, you could also implement a library with GLOBAL scope and let the first suite store the values in the library, then request the values from it in the other suite. That prevents (slow) file I/O and having to deal with file cleanup.