Forum Discussion

listensrikanth's avatar
listensrikanth
Occasional Contributor
11 years ago

How to capture an object, not by coordinates but by the object itself when recording a Keyword test?

Can anyone help me, how to capture an object, not by co-ordinates but by the object itself?



thank you
  • In my experience it has done it automatically, it may seem like it is capturing the coordinates, but if you move the object to a different place or resize it before you run the test again, it should still work.
  • listensrikanth's avatar
    listensrikanth
    Occasional Contributor
    Thanks for the suggestion. In some cases, if i resize the window and run the test, test fails.



  • listensrikanth's avatar
    listensrikanth
    Occasional Contributor
    when i resize the window, it is looking for the co-ordinates in the scripts and dragging the cursor to same co-ordinates.
  • Are you performing the tests on a Desktop application?

    Does this happen with all of your objects or just some of them?

    Are you sure TestComplete is mapping the object correctly?



    The only time I have trouble with TestComplete tracking windows is because we use TdxBarControl for our menus and they are not compiled with the debug information.
  • Ravik's avatar
    Ravik
    Super Contributor


    You might be using "Record Low Level Procedure" mode while recording your script.



    Try Normal Recording.



    or



    In case your objects are moving or height, width or position changing frequently at that time you will prefer Descriptive Programming. (Descriptive programming u need to create manually its time consuming process but most powerful and beneficial in your case )  



    Thanks

    Ravik
  • listensrikanth's avatar
    listensrikanth
    Occasional Contributor
    Yes, it is desktop application. Couldn't find the object, when i reduce the application size. Test was recorded in full size mode.
  • balathavamani's avatar
    balathavamani
    Occasional Contributor
    Hi venkata yadlapalli,



    Hope this might helpfull for you . Check and revert back.



    1. Store the object name in a variable (Get object name via object spy)



    var  a =(Sys["Process"]("Testedapp")["Object"]("HwndSource: Window", "Window"));



    2. By using Regions in Testcomplete we can save the image



     Regions["AddPicture"](a, "Image");



    Thanks

    Bala Thavamani

     
    • vjecov's avatar
      vjecov
      Occasional Contributor

      How about next object, how would you write it in a Descriptive way?

       

      var myButton = AddTheDescriptiveObjectWithPropertiesAndValues;

       

      Next are object's properties and values (I don't want to use the mapped object):

      FullName: Sys.Process("calc").Window("CalcFrame", "Calculator", 1).Window("CalcFrame", "", 1).Window("#32770", "", 2).Window("Button", "", 11);

      Name: Window("Button", "", 11)

      RecordClass: Button

       

      WndClass: Button

      Index: 11

       

      I am looking for something like this:

      var calcWindow = (Sys["Process"]("calc")["Window"]("CalcFrame:Calculator", 1)["Window"]("CalcFrame:", 1)["Window"]("#32770:", 2);
      
      var myBtn = calcWindow.["Window"]("RecordClass:Button", "WndClass:Button", "Name:Window(\"Button\", \"\", + caption)", "Index:11");
      
      myBtn.ClickButton();

      I know something is wrong in the code above but cannot figure it out, please help.