This is a little continuation of the previous post.
Multiple browser tabs implementation using CodedUI
So the scenario is a browser opened with three tabs, each one with Bing, yahoo and google opened.
Now if i wanted to close the specific browser tab in it.
this is how u do it
public void CloseTab(string tabName)
{
BrowserWindow openBrowser = new BrowserWindow();
Playback.PlaybackSettings.MatchExactHierarchy = true;
openBrowser.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
WinTabList openBrowserTabList = new WinTabList(openBrowser);
openBrowserTabList.SearchProperties[WinTabList.PropertyNames.Name] = "Tab Row";
WinTabPage myTabPage = new WinTabPage(openBrowserTabList);
myTabPage.SearchProperties[WinTabPage.PropertyNames.Name] = tabName;
Mouse.Click(myTabPage);
//myTabPage.SetFocus();
//myTabPage.DrawHighlight();
WinButton close = new WinButton(myTabPage);
close.SearchProperties.Add(WinButton.PropertyNames.Name, "Close Tab", PropertyExpressionOperator.Contains);
//close.SearchProperties[WinButton.PropertyNames.Name] = "Close Tab (Ctrl+W)";
Mouse.Click(close);
}
Happy coding :)
No comments:
Post a Comment