How to identify Windows ToolBar using CodedUI

Below code will help to click on buttons on tool bar which generally comes when we try to login into the application or try to download any file from the application.

As first action we do on the webpage so first we have to identify the webpage and then tool bar which pop-ups after performing the some actions. We have to use WinToolBar class to identify Tool Bar. So here you go-

BrowserWindow MainWin = new BrowserWindow();
MainWin.SearchProperties[BrowserWindow.PropertyNames.Name] = “Page Title Name”;
WinToolBar ToolStrip = new WinToolBar(MainWin);
ToolStrip.SearchProperties[WinToolBar.PropertyNames.Name] = “Notification”;
ToolStrip.DrawHighlight();
WinButton No= new WinButton(ToolStrip);
No.SearchProperties[WinButton.PropertyNames.Name] = “No”;
No.DrawHighlight();
Mouse.Click(No);

ToolBar1

 

Advertisements