Forum Discussion

lowres's avatar
lowres
Occasional Contributor
2 months ago
Solved

How to replace a Value with a Variable.

Hello All. Hoping you can help....

I need to select an entry from a radComboBox.
Im using ClickItem. If I clickItem and use a number it will pick the relevant Item from the list.

It also works and it pick the item by name, Sausages from the list:

Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox.wText.Sausages

Ideally I want to pick the item by actual name stored as a variable (Project.Variables.CUBEROOTWORKFLOWPROFILE)
So something like this, but I am having trouble replacing Sausages with a predefined Variable.

Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox.wText.Project.Variables.CUBEROOTWORKFLOWPROFILE

What would the syntax be to replace hard coded Sausages with the Variable stored in Project.Variables.CUBEROOTWORKFLOWPROFILE?


This does not work:
Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox.wText.Project.Variables.CUBEROOTWORKFLOWPROFILE?

Thanks for any pointer.

  • If you have a variable called FRUITNAME having the following string value "Banana[Enter]Apple[Enter]Pear" and you use the Keys operation. It will enter each fruit name followed by a carriage return. You can find more information at Keys Action.

    Scripts is different from Keyword Tests.

10 Replies

  • Hi lowres​ ,

    So you can apply variables to keyword test operations in the "Value" Column.

    1. Double click on the cell that you want to apply the variable to.
    2. On the popup window, click on the ellipsis on the far right
    3. Change the "Mode" to Variable
    4. Specify the variable in the "Value" drop down and hit OK

     

  • lowres's avatar
    lowres
    Occasional Contributor

    Hi Sean,
    So I end up with:

    Project.Variables.CUBEROOTWORKFLOWPROFILE

    But its unable to find that when I go to play it back.
    It seems to need pointing to Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox.wText.

    Error is 

    Total number of items: 5.
    Items: '', '', '', '', ''.

    Tested object:
    Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox
    (Sys.Process("Desktop").WPFObject("HwndSource: WindowHostWindow", "System.Windows.Controls.Grid").WPFObject("WindowHostWindow", "System.Windows.Controls.Grid", 1).WPFObject("XFDialogContainer", "", 1).WPFObject("MainContentControl").WPFObject("SelectWorkflowViewDlg", "", 1).WPFObject("comboBoxCubeRoots").WPFObject("radComboBox"))

    • lowres's avatar
      lowres
      Occasional Contributor

      So the question I have is there a way to include a variable in the value?

      Aliases.Desktop.HwndSource_WindowHostWindow.WindowHostWindow.radComboBox.wText.VARIABLEHERE

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        In your first screenshot, you have a name mapping called radComboBox, and you are calling the method ClickItem, to click on item '3', in your combo box

        Assuming you have already defined a persistent project variable called, Project.Variables.CUBEROOTWORKFLOWPROFILE = 3

        Then you can reference the variable, in your keyword test step like so

        which will then look something like this,

        If you change the value of your variable, the keyword test action will click that item in your combo box

  • lowres's avatar
    lowres
    Occasional Contributor

    Thanks rraghavani,

    Sorry, Im not being clear. Im just not clear on when I can use variables/how.

    For example I want to enter a fruit name into notepad then press enter.

    Types Apples and hits Enter

    Now instead of typing Apples I want to type a Variable I have stored followed by Enter key press?

    How do I concatenate an Enter key press onto the end of Variables.FRUITNAME variable?
    Is the only way to add a additional Item line?



    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      This is a slightly a different question from your original one, but the same principle applies, in using a variable. 

      Whatever value is stored in FRUITNAME variable, will be typed using the Keys operation, which is then followed by an carriage return. As shown in your screenshot,

      If you are new to TestComplete, then watch some of the tutorials shown here TestComplete Video Center | SmartBear Software

      • lowres's avatar
        lowres
        Occasional Contributor

        So a variable and an Enter press can not happen in the same item?

        I come from writing in LoadRunner and Robot Framework tools, I can just drop in predefined variables anywhere like in my scripts as needed.