Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created August 15, 2013 11:40
Show Gist options
  • Select an option

  • Save JakeGinnivan/6240189 to your computer and use it in GitHub Desktop.

Select an option

Save JakeGinnivan/6240189 to your computer and use it in GitHub Desktop.
void Main()
{
var app = Application.LaunchWindows8Application("Microsoft.BingWeather_8wekyb3d8bbwe!App");
var window = app.GetWindows().Single();
OpenAppBar();
window.Get<Hyperlink>("Home_link").Click();
OpenAppBar();
window.Get<Hyperlink>("MyPlaces_link").Click();
var tile = window.Get<GroupBox>("CommonJS_UI_ResponsiveListView_Cluster1_Content_ListView2AddTile");
tile.Click();
var citySearch = window.Get<ComboBox>("SearchTextBox");
citySearch.Enter("Sydney");
citySearch.KeyIn(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.RETURN);
Thread.Sleep(500);
window.Get<ListBox>("searchResults").Item(0).Click();
Thread.Sleep(500);
var list = window.Get<ListBox>("CommonJS_UI_ResponsiveListView_Cluster1_Content");
var foundAndRemoved = false;
foreach (var item in Retry.For(()=>list.Items, t=>t.Count == 0, TimeSpan.FromSeconds(5)))
{
if (item.AutomationElement.Current.AutomationId == "CommonJS_UI_ResponsiveListView_Cluster1_Content_ResponsiveListViewSydney,_NSW,_Australia"){
item.RightClick();
window.Get<Button>("CommonJS_UI_ResponsiveListView_Cluster1_Content_ResponsiveListViewSydney,_NSW,_Australia_DeleteButton").Click();
foundAndRemoved = true;
}
}
}
void OpenAppBar(){
Thread.Sleep(100);
Keyboard.Instance.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.LWIN);
Keyboard.Instance.Enter("z");
Keyboard.Instance.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.LWIN);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment