coded ui tests - Searching controls dynamically by adding search properties in code -
i trying identify controls @ runtime adding search properties in code , when required. using coded ui in visual studio 2012.
please refer screenshot below. test scenario is:
1) click on particular tab (the 2nd tab selected in screenshot)
the tab list fixed can create 1 control in uimap each tab.
2) inside every tab, there tabular structure data. table headings fixed number of rows , data inside rows dynamic.
3) check checkbox required tag
4) select type required tag
i have created uimap as:
added following code:
uiequipmenttagtext.searchproperties.add(new propertyexpression(wpftext.propertynames.name, "1302"));// want second row fetch respective checkbox control, using: uitestcontrol uiequipmenttagcell = uiequipmenttagtext.getparent();//get cell of tag name uitestcontrol uiequipmenttagrow = uiequipmenttagcell.getparent();//get row uitestcontrol uiequipmentcheckboxcell = uiequipmenttagrow.getchildren()[0];//get first cell i.e checkbox cell uitestcontrol uiequipmentcheckbox = uiequipmentcheckboxcell.getchildren()[0]; // checkbox control
but not working me. guess uirow control referring first row (though haven’t specified 1st row)
i not want include row number in search criteria row.
is there workaround controls want based on tag text only?
figured out solution finally..get rows , iterate find matching row
uitestcontrolcollection allrows = row.findmatchingcontrols(); foreach (uitestcontrol x in allrows) { uitestcontrol tag = x.getchildren()[1].getchildren()[0];//row->tag cell->tag text if (tag.getproperty("name").equals("1302"))//say want select row having 1302 tag { uitestcontrol checkbox = tag.getparent().getparent().getchildren()[0].getchildren()[0];//tagtext->tagcell->row->checkboxcell->checkbox mouse.click(checkbox); } }
Comments
Post a Comment