Forum Discussion

John_Laird's avatar
John_Laird
Contributor
8 years ago
Solved

how to use wildcards in object paths?

I am trying to click on a button using an object reference. Problem is, there are up to 20 variations of the path to the button. This is the path for button 1:   Aliases.ACMConfig.frmMain.panelCont...
  • tristaanogre's avatar
    tristaanogre
    8 years ago

    Actually... I would take a different approach...

    I'm assuming that the list of HourlyMeternnArchive components is dynamic... that from test run to test run there could be more or less of those items. In that case, I wouldn't use mapping at all for the specific items but, instead, use a FindChild or FindAllChildren  to dynamically find the specific item(s) I want to click on based upon a set of criteria. Mapping it with the wildcard in the criteria and having all the items basically point to the same map is going to result in a lot of ambiguous recognition. In fact, I'd go with FindAllChildren to bring back an array of all the objects and then, using a for loop, click through each one... OR, otherwise use the array to interact with the individual components.  Probably better in the long run than wildcarding things.


     

    [EDIT] even if the list of objects isn't dynamic and is a fixed length, you could still use "FindAllChildren" to create an object in memory containing the list of all the objects.  Then, all you would have to do is reference by index... something like:


     

    //BTW... this is a HORRENDOUS mapping... consider in the Aliases section of NameMapping that you reduce this down to something more manageable
    
    var ChildList = Aliases.ACMConfig.frmMain.panelControl1.superTabControl1.suptabConfiguration.userControlConfiguration1.toolStripContainer2.ToolStripContentPanel.tabObjects.acmObjectView.acmObjectView.DocumentsHost.DocumentContainer.panelMain.panelMain_Container.tabControlOptions.tabConfiguration.userControlAsiCustomDialog.tabControl1.tabPage8.gbMeters.FindAllChildren("WndClass", "ReferenceButton"); //This is just a guess... you would need to fill in proper properties etc
    ChildList(0).Click() //Would click on btnReferenceSelect_HourlyMeter1Archive or whatever is first in the list.. etc.