public void ShouldBeEmpty() { _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select(); var basketContents = _universe.Window.Find <GridView>("basketOutput"); Assert.IsTrue(basketContents.IsEmpty()); }
public void ShouldContain(string name, double price) { _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select(); var basketContents = _universe.Window.Find <GridView>("basketOutput"); Assert.True(basketContents.ContainsRow(name, price.ToString("0.00"))); }
public void ShouldDetermineIfItContainsARowWithTheGivenHeaderAndPropertyCondition() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); Assert.True(gridView.ContainsRow("Name", FindBy.WpfText("Dancer"))); }
public void ShouldProvideItsTextByCell() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); Assert.AreEqual("Dancer", gridView.TextAt(0, 2)); }
public void ShouldBeAbleToRetrieveTheRowIndexForARowWithTheGivenHeaderAndPropertyCondition() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); Assert.AreEqual(2, gridView.IndexOf("Name", FindBy.WpfText("Dancer"))); }
public void ShouldAllowTextToBeRetrievedFromBlock() { Window window = LaunchPetShopWindow(); window.Find <Tab>(FindBy.WpfText("History")).Select(); var block = window.Find <TextBlock>("historyDescription"); Assert.AreEqual("A short summary of what has already happened:", block.Text); }
public void ShouldScrollUntilCheckIsTrue() { var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("Accessories")); tab.Select(); var scrollViewer = tab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true)); scrollViewer.ScrollDown(s => s.Contains(FindBy.WpfText("Flea powder")), s => Assert.Fail("Should have found row")); }
public void ShouldProvideAContextMenuIfItExists() { var window = LaunchPetShopWindow(); var label = window.Find <Label>(FindBy.WpfText("(Right-click here to copy an existing pet's details)")); var contextMenu = label .InvokeContextMenu(FindBy.WpfName("copyPetMenu")); contextMenu.Select(contextMenu.Items[0]); }
public void ShouldBeAbleToRetrieveTheElementReferencedByColumnAndRow() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); var cell = gridView.ElementAt <Label>(0, 2); Assert.AreEqual("Dancer", cell.Text); }
public void ShouldAllowTabToBeSelected() { var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History")); Assert.False(tab.HasFocus()); tab.Select(); Assert.True(tab.HasFocus()); }
public void ShouldBeAbleToRetrieveTheElementReferencedByARowWithHeaderMatchingAPropertyConditionFromSecondHeader() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); var cell = gridView.FindReferencedElement <Label>("Name", FindBy.WpfText("Dancer"), "Price"); Assert.AreEqual(54.00.ToString("0.00"), cell.Text); }
public void ShouldProvideAllAvailableText() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); Assert.AreEqual(3 * 4, gridView.AllText.Length); Assert.AreEqual("Dancer", gridView.AllText[2, 0]); }
public void ShouldDetermineIfItContainsARow() { _window = LaunchPetShopWindow(); _window.Find <Tab>(FindBy.WpfText("History")).Select(); var gridView = _window.Find <GridView>("lastPetsOutput"); Assert.IsTrue(gridView.ContainsRow("Dancer", "Rabbit", 54.00.ToString("0.00"), "False")); Assert.IsFalse(gridView.ContainsRow("Prancer", "Reindeer", 30.00.ToString("0.00"), "False")); }
public void ShouldAllowTextToBeEnteredIntoTheTextBox() { Window window = LaunchPetShopWindow(); window.Find <Tab>(FindBy.WpfText("History")).Select(); var box = window.Find <RichTextBox>("historyInput"); box.Text = "Gooseberry Bear"; Assert.AreEqual("Gooseberry Bear", box.Text); }
public void ShouldHandleFailureToScroll() { var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("Accessories")); tab.Select(); var scrollViewer = tab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true)); var complained = false; scrollViewer.ScrollDown(s => false, s => complained = true); Assert.True(complained, "Should have handled failure to scroll"); }
public void ShouldPassFailureHandlerToChildContainers() { var container = LaunchPetShopWindow(); var complained = true; container.HandlerForFailingToFind = s => complained = true; var childContainer = container.Find <Tab>(FindBy.WpfText("Basket")); childContainer.Find <ComboBox>("Unlikely!"); Assert.True(complained, "Should have handled failure to find using the given handler"); }
public void ShouldWaitForTabToBeSelected() { var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History")); new Thread(o => { Thread.Sleep(100); tab.Select(); }).Start(null); Assert.True(tab.WaitFor( (src, e) => tab.HasFocus(), src => Assert.Fail())); }
public void ShouldWaitForTextToBeChanged() { Window window = LaunchPetShopWindow(); window.Find <Tab>(FindBy.WpfText("History")).Select(); var box = window.Find <RichTextBox>("historyInput"); new Thread(o => { Thread.Sleep(100); box.Text = "Fred"; }).Start(null); Assert.True(box.WaitFor( (src, e) => box.Text.Equals("Fred"), src => Assert.Fail())); }
public void ShouldWaitForContentsOfBlockToChange() { var window = LaunchPetShopWindow(); var tab = window.Find <Tab>(FindBy.WpfText("History")); tab.Select(); new Thread(() => { var box = window.Find <RichTextBox>("historyInput"); box.Text = string.Empty; }).Start(); var block = window.Find <TextBlock>("historyOutput"); block.WaitFor((b, e) => ((TextBlock)b).Text.Equals(string.Empty), b => Assert.Fail("Should have had empty text")); Assert.AreEqual(string.Empty, block.Text); }
public void AreSelected(params string[] accessoryNames) { var accessoriesTab = _universe.Window.Find <Tab>(FindBy.WpfText("Accessories")); accessoriesTab.Select(); var scrollViewer = accessoriesTab.Find <ScrollViewer>(new PropertyCondition(AutomationElement.IsScrollPatternAvailableProperty, true)); var table = accessoriesTab.Find <ListBox>("accessoriesOutput"); foreach (var name in accessoryNames) { var nameForThisLoop = name; scrollViewer.ScrollDown(s => s.Contains(nameForThisLoop), s => {}); scrollViewer.ScrollUp(s => s.Contains(FindBy.WpfText(nameForThisLoop)), (s2) => Assert.Fail("Should have scrolled to {0}" + nameForThisLoop)); } table.Select(CollectionUtils.Convert(accessoryNames, name => "Accessory[" + name + "]").ToArray()); }
public void ShouldFindAnElementBasedOnAProperty() { var window = LaunchPetShopWindow(); var basket = window.Find <Tab>(FindBy.WpfText("Basket")); AutomationElement comboBoxElement = window.Element.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ClassNameProperty, typeof(ComboBox).Name)); string comboBoxName = comboBoxElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty).ToString(); var wrapperFactory = new Mock <IWrapAutomationElements>(); var comboBox = new ComboBox(comboBoxElement, "aComboBox"); wrapperFactory.Setup(x => x.Wrap <ComboBox>(comboBoxElement, comboBoxName)).Returns(comboBox); var finder = new ConditionBasedFinder(wrapperFactory.Object, new Mock <IDescribeConditions>().Object); finder.Find <ComboBox>(basket, FindBy.ControlType(ControlType.ComboBox), Assert.Fail); }
public void IsReset() { _universe.Window.Find <Tab>(FindBy.WpfText("Basket")).Select(); _universe.Window.Find <Button>("resetButton").Click(); }
public void ShouldProvideItsTitle() { var tab = LaunchPetShopWindow().Find <Tab>(FindBy.WpfText("History")); Assert.AreEqual("History", tab.Title); }