You are on page 1of 2

using

using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Diagnostics;
System.Linq;
System.Text;
System.Threading;
System.Threading.Tasks;
System.Windows.Automation;
TestStack.White;
TestStack.White.Factory;
TestStack.White.UIItems;
TestStack.White.UIItems.Finders;
TestStack.White.UIItems.ListBoxItems;
TestStack.White.UIItems.WindowItems;
TestStack.White.UIItems.WPFUIItems;
TestStack.White.UIItems.MenuItems;
TestStack.White.UIItems.TabItems;
TestStack.White.UIItems.WindowStripControls;
TestStack.White.Utility;

namespace MMGui
{
public class RunDown
{
private Window _window;
public static Label _myStoryLabel;
public static Label _myStoryTimeLabel;
public RunDown(Window window)
{
_window = window;
Thread.Sleep(1000);
}
public void SetNext(string slug)
{
Label storySlug = GetStory(slug);
storySlug.RightClick();
TestStack.White.UIItems.MenuItems.PopUpMenu popupMenu = _window.Popu
p;
// Menu level2Menu = popupMenu.ItemBy(SearchCriteria.ByAutomationId(
"mnuI_SetAsNextStory"));
//Menu level2Menu = popupMenu.Item("Edit","Insert story");
Menu level2Menu = popupMenu.Item("Set As Next Story");
level2Menu.Click();
}
private Label GetStory(string slug)
{
TestStack.White.UIItems.ListBoxItems.ListBox theListBox =
_window.Get<TestStack.White.UIItems.ListBoxItems.ListBox>("lst_St
ories");
foreach (ListItem item in theListBox.Items)
{
AutomationElement child = TreeWalker.RawViewWalker.GetFirstChild

(item.AutomationElement);
Label storySlugLabel = GetStorySlugLabel(child);
if (storySlugLabel.Text == slug)
{
_myStoryLabel = storySlugLabel;
}
}
return _myStoryLabel;
}
private Label GetStorySlugLabel(AutomationElement child)
{
List<AutomationElement> result = new List<AutomationElement>();
while (child != null)
{
result.Add(child);
child = TreeWalker.RawViewWalker.GetNextSibling(child);
}
//
}
}
}

string slug = result[4].Current.Name;


Label storySlug = new Label(result[4], _window);
return storySlug;

You might also like