Forum Discussion

savyan's avatar
savyan
Occasional Contributor
11 years ago

Convert script to Keyword tests

I am not sure whether this is a relevant question or not, Is it possible to convert script to Keyword tests anyhow the other way is possible? We tried this but not found any option to convert script to its corresponding keyword tests.

 

Thanks 

Savya

4 Replies

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor

    Hi Savyan

     

    I don't think this is possible, unless you attempt to re-create a keyword test manually, based on what the script is actually doing, but I think that it's possible to do more sophisticated things with script than with keyword tests, so it might not always be possible, at least not easily!!

     

    Regards

    Stephen.

    • savyan's avatar
      savyan
      Occasional Contributor

      Hi Stephen,

       

      Thanks for your reply. Realy am ot concerned about the conversion of scripts. I just asked this because am in the middle of some other issue.

      Actually i wanted to do something with a drop down list. I am unable to select the particular data from the dropdown list. Manually the scenario is scrolling the dropbox down and select the value. But testcomplete has issue either with scrolling or with value selection. I just want to know is there any particular method to select a value from the dropdown list. Please note that the value in the list will be visible only if i scroll down the dropbox.

       

      Thanks,

      Savya

      • sbkeenan's avatar
        sbkeenan
        Frequent Contributor

        Hi

         

        Do you know what type of control it is, i.e. is it a third part control, like DevXpress?  testComplete has support for such third party controls, but it depends on teh specific control and its version.

         

        If it's supported, there is usually a 'ClickItem' method that you can use - you shouldn't need to specifically scroll the dropdown list to make the item visible.  If it's not supported then you'll have to use the native properties and methods that are available to you.  Sorry I can't be more specific, but without the name of the control, it's difficult!!  However, should you need to specifically scroll an item into view, there is usually a 'ScrollIntoView' method available.  Again, this depends on the type of control and whether it's supported.

         

        If it's of any help (it should at least give you an idea), I've provided an example below:

         

        /**
         * S E T  L O O K U P  E D I T
         * Public function to select an item from a Dev.X 'LookUpEdit' type combo box
         * control.
         * 
         * @param   lookUpEditCtrl    The LookUpEdit control object.
         * @param   item              A string value to select an item by name or a numeric value
         *                            to select an item by its index.
         *
         * @return  If 'item' is a string value, the function returns True if the item is found, otherwise 
         *          it leaves the control with its last selection and returns False.
         *          If 'item' is a numeric value, i.e. an index, then the function returns an array
         *          where element (0) is True and element (1) is the selected index's text if the item
         *          was found, otherwise element (0) is False and element (1) is set to an empty string.
         */
        function setLookUpEdit(lookUpEditCtrl, item)
        {
           var result;
           if (isNaN(item))   //item is a text value
           {
              item = item.toString();
              var i = lookUpEditCtrl.FindItem_2(item, false, 0);
              if (i >= 0) //item found
              {
                 lookUpEditCtrl.setFocus();
        	 lookUpEditCtrl.set_ItemIndex(i);
                 result = true;
              }
              else
              {
                 result = false;
              }
           }
           else  //item is a numeric value
           {
              result = [];
              if (item >= 0 && item < lookUpEditCtrl.wItemCount)
              {
                 lookUpEditCtrl.clickItem(item); 
                 result[0] = true;
                 result[1] = lookUpEditCtrl.Text;
              }
              else
              {
                 result[0] = false;
                 result[1] = "";
              }
           }
              
           return result;
        }

         

        This example is for a DevXpress LookUpEdit control that I use specifically for my needs, feel free to use it/modify it, but please understand that I cannot be held responsible for anything that goes wrong with it - It's an example only!!

         

        Regards

        Stephen.