c# - System.WIndows.Forms.Ribbon controls in CodedUI -
i developing c# winform application. have ribbon in form contains several tabs , several ribbonbuttons. using coded ui testing. problem facing unable find ribbonbuttons using coded ui, whenever hover on control of ribbon (say ribbonbutton), detects ribbon not control. can 1 suggest whether ribbon controls supports coded ui testing? if yes, how can so?
there ribbonbar inside ribbonbar found.
here code: file tab open button
var mainwindow = new winwindow(app); mainwindow.searchproperties.add(winwindow.propertynames.controlname, "frmmain"); var ribbonbar = new winwindow(mainwindow); ribbonbar.searchproperties.add(winwindow.propertynames.controlname, "radribbonbar"); var ribbonbarinside = new winmenubar(ribbonbar); ribbonbarinside.searchproperties.add(winwindow.propertynames.name, "radribbonbar"); //name not controlname!! assert.istrue(ribbonbarinside.tryfind()); var tabs = new wintabpage(ribbonbarinside); var tab = tabs.findmatchingcontrols().where(t => (t wintabpage).accessibledescription.trim() == "file").firstordefault(); assert.isnotnull(tab); mouse.click(tab); var buttons = new winbutton(ribbonbarinside); var button = buttons.findmatchingcontrols().where(t => (t winbutton).accessibledescription.trim() == "open").firstordefault(); assert.isnotnull(button); //mouse.click(button); <-- throw exception, next 2 lines solve this. mouse.location = new point(button.left + button.width / 2, button.top + button.height / 2); mouse.click();
Comments
Post a Comment