Forum Discussion

nisgupta's avatar
nisgupta
Valued Contributor
9 years ago

Generic function for object containing search and drop down

I have attached the screenshot of object , I am trying to create the generic function for this object . Details are in the comment 

 

Please update how can we create the generic function . generic function in term of passing Naming mapping as parameters or values if applicable.

 

Thanks

Nishchal

12 Replies

  • nisgupta's avatar
    nisgupta
    Valued Contributor

    I do have some issue with object spy . Whenever I select the object to display the drop down list and do Object spy then drop down list get closed . So cannot recognize 

    • sanjay0288's avatar
      sanjay0288
      Frequent Contributor

      To get the properties of drop down.. Open object spy and select ->Point and Fix option(Ctrl+Shift+A). This makes object spy to be in pointing mode. Click on dropdown in your Application. Point to the dropdown box once a red border appears on your dropdown press Ctrl+Shift+A. Now you will be able to get the properties of the dropdown.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What class of object is it? What properties does it have?  While we can see the GUI layer of the rendered object, it doesn't do us much good to be able to give you a generic function without more detail about what kind of object it is.

    I don't think we need an object spy of the drop down list for starters.  However, we do need the properties of the actual search control so we can help you write the code for it.

  • sanjay0288's avatar
    sanjay0288
    Frequent Contributor

    What is the exact requirement? The approach would be a function where you are passing "itemName" which would be present in the dropdown list.

     

    What you have to do is Click on the search box so that dropdown comes and use the clickitem method to click on an item which is present in the dropdown.

     

     

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    As part of creating generic function for this kind of control, you can create function like below,

     

    function searchandClickDropDown(dropDownMainobject,valuetoSearch,valuetoSelect)
    {
          //dropDownMainobject is the object which will have the dropdown list with text box.
          var txt_box_proparr = new Array("<mentione your property name to find textbox>");
          var txt_box_valarr = new Array("<mentione your property value to find textbox>");
          
          var lst_proparr = new Array("<mentione your property name to find drop down object>");
          var lst_valarr = new Array("<mentione your property value to find drop down object>");
          
          if(dropDownMainobject.Exists)
          {
                var txtObject = dropDownMainobject.FindChild(txt_box_proparr,txt_box_valarr);
                var lstObject = dropDownMainobject.FindChild(lst_proparr,lst_valarr);
                
                dropDownMainobject.Click();//To display the drop down.
                
                txtObject.Keys(valuetoSearch);
                
                if(lstObject.wItemCount > 0)
                {
                      lstObject.ClickItem(valuetoSelect);
                      return true;
                } 
                     
          } 
          return false;
    }
    • nisgupta's avatar
      nisgupta
      Valued Contributor

      Here the issue is testcomplete not able to recognize the search text box with unique properties . I am attaching the screenshot. This also include how firebug recognize the search text box.

       

      Thanks

      NG

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        If there are no other text boxes within the hierarchy of the parent object, then the ObjectType of 'textbox' is sufficient identification.  You can add other properties such as ObjectIdentifier (current value 0) to your mapping properties to add additional information.  But based upon what I'm seeing, you SHOULD be able to map that object just fine.  You can object spy it enough to get the property listing.

         

        But, apparently, something is not working or you wouldn't still be asking.  so...  are you getting an error message when you try to use the mapped object in a test case?  If so, what is it?