Forum Discussion

tanvi_agarwal's avatar
tanvi_agarwal
Occasional Contributor
11 years ago
Solved

How to use ID property of an object and apply methods on it

Hi,



I used to use visual studio for automation earlier.

In VS if I want to click on a radio button with a specific ID we used to use this.browser.Button(Find.ByID("radiobutton1")).Click();

This used to click on the radio button.



Other example can be:

this.browser.SelectList(Find.ByName("Countrylist")).SelectByValue(country);



Similarly we used to use these methods of the objects to read text and store it in the variables and for many more actions.



Please could someone tell me how to carry out a similar function in Test Complete as I want it to read all my objects available on the page using their and ID and perform functions on it.  

Thanks,

Tanvi

















7 Replies

  • paul_scroce's avatar
    paul_scroce
    Frequent Contributor


    Try something like



     



    var control;



     



    // Searches for the control



    control = Aliases["browser"]["page1"]["Find"]("ID", "Submit", 1000);



    // Processes the search results



    if (control["Exists"])



    control["Click"](5, 5);



    else



    Log["Error"]("The object was not found.");


  • tanvi_agarwal's avatar
    tanvi_agarwal
    Occasional Contributor
    Hi Jose,



    Thanks for your reply.

    But when I am trying to use Find then it is throwing an error saying that it is a mismatch.



    Please can you write a line of code.



    for eg. if I want to click on a Button with ID  "submit" on  page Aliases["browser"]["page1"], then please could you tell me how to code this line in C#.



    Thanks a lot.



    Tanvi
  • jose_pita's avatar
    jose_pita
    Super Contributor
    Sorry, I don't use connected apps, my scripts are in JScript directly on testcomplete.



    Maybe someone else can help you with that.
  • tanvi_agarwal's avatar
    tanvi_agarwal
    Occasional Contributor
    Hi Paul,



    Thanks for your reply.



    It was of great help.



    I tried using the code but each time it is unable to find the object and logs the error message "Object not found". 



    I checked the name mapping also but cannot figure out the reason.

    Please could you suggest.



    Thanks,

    Tanvi