Forum Discussion

nedbacan's avatar
nedbacan
Frequent Contributor
2 years ago
Solved

Selecting an item from List box based on the name using

Hello, I am fairly new to Test Complete and just learning, can someone show me using my example I provided here on selecting the specific item (see screenshot) from the web List box that I show highl...
  • Kitt's avatar
    2 years ago

    In basic scripting, without a dynamic variable, finding and clicking the object is just:

     

    Sys.Browser("*").Page("*").FindElement("//div[.='Refracnadim1 1_Refractionist']").Click();

     

     And if you're using a Project.Variable, it would be something like:

     

    Sys.Browser("*").Page("*").FindElement("//div[.='" + Project.Variable.ListItemX + "']").Click();

     

     

    That being said, it looks like you are using NameMapping within TestComplete, so if it is indeed a mapped object, to click it you would just use:

     

     

    Aliases.browser.pageWHATEVER.label.panelRefracnadim11Refractionist.Click();

     

     

    If this object's xpath has a dynamic property variable that you pass in from another test, you'll need to insure:

    1. You are using Project.Variable and not a ProjectSuite.Variable.
    2. You'll want to update the object in NameMapping to use the Project.Variable in the property criteria (see how here). EX: if your variable name was ListItemX for example, the xpath in the NameMapping would be //div[., '%ListItemX%'].
    3. (Optional) Change the object Name and Alias from panelRefracnadim11Refractionist to panelRefracnadimRefractionist (or similar) for ambiguity and assuming the number changes. This allows you to only need 1 mapped object for every item in the list - assuming you are using the variable approach to pass in the dynamic part of the xpath, and assuming the parent object is mapped appropriately (IE: mapping the container box the list items are in //div[contains(@class, 'practitioner-container')]).