Forum Discussion

Azeddin_Margani's avatar
Azeddin_Margani
Contributor
12 years ago

Combining Text fields into one

Hi,



I need to combine the values of 2 text fields into one value.



The 2 fields are showing in a dialog box as follows: 

{Data Name}: TestOne

{Data Description}: From 18/05/2014 to 13/12/2014. SX LTP



The two 2 fields make a combined name such as: TextOne From 18/05/2014 to 13/12/2014. SX LTP which will be added into an Item list.



I need to be able to select this item "TextOne From 18/05/2014 to 13/12/2014. SX LTP" from the item list.   



I used the function, ...ClickItem() with no success - I need to know how to:



1. Extract the value of field {Data Name}, then

2. Extract the value of field {Data Description}, then

3. combine both fields to make the name, then

4. Select Item/name from list.



Is there a simple way to do this in JavaScript?.



Regards,

A.M.











5 Replies

  • Hi Azeddin,

     


    Pseudocode for your task may look like this:




    var data = Sys.Process("<Your_Tested_App>").Obj.Obj....DataObject.Value;


    var desc = Sys.Process("<Your_Tested_App>").Obj.Obj....DataDesciptionObject.Value;


    var itemName = data + " " + desc + ". SX LTP";


    var cbox = Sys.Process("<Your_Tested_App>").Obj......Combobox.ClickItem(itemName);




     


    If this doesn't work for you, give us more details:


     - What app are you testing (.NET, VCL, etc.)?


     - What controls are used in the app?


     - If the controls aren't standard, what are their names and vendors?


     

  • Hi Tanya,



    Thanks for the reply. I was able to capture the text for both fields but the issue I'm having is that the fields and the Item list are located in two different dialog boxes (i.e. in the first dialog where I need to capture the text value (in one script) and in the second dialog where I need to be able to select the combined name (in another script)).



    The 2 scripts need to share the captured data b/w them.



    I tried to setup "data" and "desc" variables as Global (Persistence Variables) but when I execute, the error 'data' and 'desc' is undefined.



    I guess the question is - where these variables should be defined globally  as they are located in the same project . 



    Thanks,

    A.M. 
  • Hi Azeddin,

     


    Are these different scripts located in one project? In this case, you can use project variables to keep the needed data.


    If the scripts are stored in different projects, project suite variables can be used.


    The syntax for project variables will be like this:


    Project.Variables.data


    Project.Variables.desc