Forum Discussion

Nayak_Ragh's avatar
Nayak_Ragh
Occasional Contributor
4 years ago

Referencing a Unique ID from one test into another

I have a Keyword test in desktop application which generates an Order ID and I need to reference this Order ID in another test.

When I spy the result, this is what it looks like :

Aliases.Ax32.Sales_order_1_1000_Sales_order_SG1792246_Seneca_Corporation_.TaskPageLayout.PartHostSplitContainer.SplitterPanel.NativeWindowControl.NativeWindowWithEvents.SalesTable.AxTabCtrl.AxPaneWnd.AxPaneWnd.SG1792246_100025_Seneca_Corporation

 

and 'SG1792246' is the Order ID I need to reference in another test.

 

Please help resolve the issue. I tried 'Set Variable value' but unable to split just the Order ID.

 

2 Replies

  • tphillips's avatar
    tphillips
    Frequent Contributor

    You can still use Set Variable Value, but set the Mode to Code Expression. You'll have to come up with a code expression to split the string.

    Split it around the "." character, then grab the last element, split it around underscores and grab the first element. That's your sales ID

    You could also grab it from earlier in the string with a different split.

     

    You'll also have to make sure to use a project variable so its value doesn't get lost (I am not sure if variables on other keyword tests go out of scope)

    • Nayak_Ragh's avatar
      Nayak_Ragh
      Occasional Contributor

      Thank you for your inputs. I am halfway through and successfully able to split the data as needed and captured the order id.

      However, I am missing how to call this function at the step level wherever the OrderID need to be called.

      Could you please advise what should be the 'Operation' and the 'Value' at the step level?