public void ThenIShouldBeAbleToEvaluateThePrinciplesAndPractices() { var firstPrinciple = _mainWindow.Get <ListBox>("principlesListView").Items[0]; var slider = firstPrinciple.GetElement(SearchCriteria.ByControlType(typeof(Slider))); Assert.That(slider.Current.IsOffscreen, Is.False); }
public void FindUIItemsBasedOnControlTypeAndSearchCriteria() { tab.SelectTabPage("Winter"); var box = window.Get <TextBox>(SearchCriteria.ByControlType(ControlType.Edit).AndIndex(1)); Assert.AreNotEqual(null, box); }
public void Merge() { Assert.That(SearchCriteria.ByAutomationId("foo").Merge(SearchCriteria.ByControlType(ControlType.Button)), Is.EqualTo(SearchCriteria.ByAutomationId("foo").AndControlType(ControlType.Button))); Assert.That(SearchCriteria.ByAutomationId("foo").Merge(SearchCriteria.ByControlType(ControlType.Button).NotIdentifiedByText("bar")), Is.EqualTo(SearchCriteria.ByAutomationId("foo").AndControlType(ControlType.Button).NotIdentifiedByText("bar"))); }
public void AddReference(string referenceName) { var solutionExplorerTab = window.Get(SearchCriteria.ByText("Solution Explorer")); // Focus the tab solutionExplorerTab.Click(); var solutionExplorerTree = window.Get <Tree>(SearchCriteria.ByAutomationId("SolutionExplorer")); var node = FindAutomationElement(solutionExplorerTree.AutomationElement, "References"); var nodeItem = new UIItem(node, window); // Focus nodeItem.Click(); // Click nodeItem.RightClick(); window.Popup.Item("Add Reference...").Click(); var dialog = window.ModalWindows()[0]; var listItem = dialog.Get(SearchCriteria.ByText(referenceName)); listItem.Click(); var checkBox = listItem.Get <CheckBox>(SearchCriteria.ByControlType(ControlType.CheckBox)); checkBox.Checked = true; dialog.Get <Button>(SearchCriteria.ByText("OK")).Click(); }
private void ShowControl(TreeNode node) { Window window = node.Tag as Window; if (window == null) { return; } Cursor = Cursors.WaitCursor; // search for children SearchCriteria crit = SearchCriteria.ByControlType(ControlType.Button); IUIItem[] buttons = window.GetMultiple(crit); crit = SearchCriteria.ByControlType(ControlType.Text); IUIItem[] edits = window.GetMultiple(crit); crit = SearchCriteria.ByControlType(ControlType.CheckBox); IUIItem[] checkboxes = window.GetMultiple(crit); node.Nodes.Clear(); // add child nodes ShowGroupControl(node, "[Buttons]", buttons); ShowGroupControl(node, "[Textboxes]", edits); ShowGroupControl(node, "[Checkboxes]", checkboxes); Cursor = Cursors.Arrow; }
public virtual List <T> FindAll <T>() { return(current .GetAll(SearchCriteria.ByControlType(ControlDictionary.Instance.GetControlType(typeof(T)))) .OfType <T>() .ToList()); }
private static void AddFromAvailableFields(Window windowSelectedFields, string columnName) { ListView listSelectedFields = windowSelectedFields.Get <ListView>(SearchCriteria.ByControlType(ControlType.DataGrid).AndIndex(0)); ListViewRow row = listSelectedFields.Rows.First(r => r.Name == columnName); row.DoubleClick(); }
public Button getButtonByText(String button_text) { var buttons = extensionClass.GetMultipleWithWait(win, SearchCriteria.ByControlType(ControlType.Button)); try { foreach (TestStack.White.UIItems.Button b in buttons) { if (b.Enabled == true && b.Text.Equals(button_text)) { try { Random rnd = new Random(); Utilities.takeScreenShot(b); } catch (Exception e) { Console.WriteLine(e.Message); } return(b); } } } catch (Exception) { return(null); } return(null); }
public static void SelectFromList(string title, string item) { Window windowFields = GetWindow(title); Table listFields = windowFields.Get <Table>(SearchCriteria.ByControlType(ControlType.Table)); listFields.Rows[0].Cells[5].Click(); }
public static void WaitOpenSpan() { Console.WriteLine("Launch WaitOpenSpan() procedure"); Thread.Sleep(35000); for (int i = 1; i < 5; i++) { Console.WriteLine("Attempt " + i.ToString() + " of 5"); System.Diagnostics.Process[] myProcess = System.Diagnostics.Process.GetProcesses(); foreach (System.Diagnostics.Process p in myProcess) { if (p.ProcessName.Contains("OpenSpan.Runtime")) { White.Core.Application OpenSpan = White.Core.Application.Attach("OpenSpan.Runtime"); Thread.Sleep(5000); var OpenSpanPanels = Desktop.Instance.GetMultiple(SearchCriteria.ByControlType(ControlType.Pane)); foreach (var OpenSpanPanel in OpenSpanPanels) { Console.WriteLine("Search OpenSpan application Bar"); if (OpenSpanPanel.Name.Contains("Application Bar")) { return; } } } } Thread.Sleep(3000); } }
private void CloseAlertAndGetItsText(Window dialogForm, bool alertAcc) { Panel btnPanel = dialogForm.Get <Panel>("uxContainerTableLayoutPanel").Get <Panel>("uxButtonsFlowLayoutPanel"); string txtBtn = btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button)).Name; if (alertAcc) { switch (txtBtn) { case "Yes": btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("Yes")).Click(); break; case "No": btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("Yes")).Focus(); btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("Yes")).Click(); break; } } else { switch (txtBtn) { case "Yes": btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("No")).Focus(); btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("No")).Click(); break; case "No": btnPanel.Get(SearchCriteria.ByControlType(ControlType.Button).AndByText("No")).Click(); break; } } }
public string GetResult() { var modalWindow = _window.ModalWindow("Result"); Label lbl = (Label)modalWindow.Get(SearchCriteria.ByControlType(ControlType.Text)); return(lbl.Text); }
// BUG: only works for the English translation public void HashesTest(string name, bool interrupt, string def_expected_results, string full_expected_results) { // Reset the selected checksums back to the default RegistryKey reg_key = Registry.CurrentUser.OpenSubKey("SOFTWARE"); reg_key = reg_key.OpenSubKey("HashCheck", true); // (true == with-write-access) if (reg_key != null) { reg_key.DeleteValue("Checksums", false); // (false == no-exceptions-if-not-found) } Window prop_window = OpenHashPropWindow(name); try { VerifyResults(prop_window, def_expected_results); // If we should try to interrupt hash calculation in-progress, restart it // (VerifyResults() above waits for completion, the following does not) if (interrupt) { prop_window.Close(); prop_window = null; prop_window = OpenHashPropWindow(name); } // Open the options dialog prop_window.Get <Button>("Options").Click(); Window options_window = null; while (true) { foreach (Window mw in prop_window.ModalWindows()) { if (mw.Name.StartsWith("HashCheck Options")) { options_window = mw; goto options_window_found; } } System.Threading.Thread.Sleep(0); } options_window_found: // Enable all the hash option checkboxes and click OK foreach (CheckBox cb in options_window.GetMultiple(SearchCriteria.ByControlType(ControlType.CheckBox))) { cb.State = ToggleState.On; } options_window.Get <Button>("OK").Click(); VerifyResults(prop_window, full_expected_results); } finally { if (prop_window != null) { prop_window.Close(); } } }
private static void CreateNewGroup(GroupData group, Window dialogue) { dialogue.Get <Button>("uxNewAddressButton").Click(); TextBox textBox = (TextBox)dialogue.Get(SearchCriteria.ByControlType(ControlType.Edit)); textBox.Enter(group.Name); Keyboard.Instance.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN); }
public void GetMultiplePanes() { IUIItem pane = window.Get(SearchCriteria.ByControlType(ControlType.Pane).AndAutomationId("panelWithText")); Assert.AreNotEqual(null, pane); IUIItem[] multiple = window.GetMultiple(SearchCriteria.ByControlType(ControlType.Pane).AndAutomationId("panelWithText")); Assert.AreNotEqual(0, multiple.Length); }
/* public static AutomationElement.AutomationElementInformation findElement_Dialog(this API_GuiAutomation guiAutomation) * { * var processID = guiAutomation.TargetProcess.Id; * var finder = new AutomationElementFinder(AutomationElement.RootElement); * var automationElementInformation = finder.FindWindow(SearchCriteria.ByControlType(ControlType.Window),processID).Current; * return automationElementInformation; * }*/ public static AutomationElement.AutomationElementInformation findElement_Image(this API_GuiAutomation guiAutomation) { var processID = guiAutomation.TargetProcess.Id; var finder = new AutomationElementFinder(AutomationElement.RootElement); var automationElementInformation = finder.FindWindow(SearchCriteria.ByControlType(ControlType.Image), processID).Current; return(automationElementInformation); }
public virtual StatusStrip StatusBar(InitializeOption initializeOption) { var statusStrip = (StatusStrip)Get(SearchCriteria.ByControlType(ControlType.StatusBar)); statusStrip.Cached = initializeOption; statusStrip.Associate(WindowSession); return(statusStrip); }
public void GivenIHaveDoneNearlyEnoughRetrospectivesToAdvanceALevel() { _mainWindow.Get <Button>("retrospectiveButton").Click(); var firstPrinciple = _mainWindow.Get <ListBox>("principlesListView").Items[0]; var slider = firstPrinciple.GetElement(SearchCriteria.ByControlType(typeof(WPFSlider))); // how to slide slider to value 100? ScenarioContext.Current.Pending(); }
public virtual List <T> FindAll <T>() { return(ControlDictionary.Instance .GetControlType(typeof(T), automationElement.Current.FrameworkId) .SelectMany(ct => current .GetAll(SearchCriteria.ByControlType(ct)) .OfType <T>()) .ToList()); }
public bool ImageShown() { var barManager = GetByAutomationId <GroupBox>("BarManager"); var toolStrip = barManager.Get <ToolStrip>("StatusBar"); var statusButton = toolStrip.Get <Button>(SearchCriteria.ByAutomationId("StatusMessage")); var imagePart = statusButton.Get <Image>(SearchCriteria.ByControlType(ControlType.Image)); return(imagePart.VisibleImage != null); }
public string GetStatusMessage() { var barManager = GetByAutomationId <GroupBox>("BarManager"); var toolStrip = barManager.Get <ToolStrip>("StatusBar"); var statusButton = toolStrip.Get <Button>(SearchCriteria.ByAutomationId("StatusMessage")); var textPart = statusButton.Get <Label>(SearchCriteria.ByControlType(ControlType.Text)); return(textPart.Text); }
public void ScrollAndSelectInAComboBox() { var listView = window.Get <ListView>("listView"); ListViewRow row = listView.Rows[0]; var comboBox = (ComboBox)row.Get(SearchCriteria.ByControlType(ControlType.ComboBox)); Assert.AreNotEqual(null, comboBox); comboBox.Select("%"); Assert.AreEqual("%", comboBox.SelectedItem.Text); }
public void FindContainer() { Window window = Desktop.Instance.Windows().Find(obj => obj.Title.Contains("Microsoft Visual Studio")); if (window == null) { return; } window.MdiChild(SearchCriteria.ByControlType(ControlType.Pane).AndByText("UIItemContainerTest.cs")); }
public void Add(GroupData newGroup) { Window dialogue = OpenGroupsDialog(); dialogue.Get <Button>("uxNewAddressButton").Click(); TextBox textBox = (TextBox)dialogue.Get(SearchCriteria.ByControlType(ControlType.Edit)); textBox.Enter(newGroup.Name); Keyboard.Instance.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN); CloseGroupsDialog(dialogue); }
private void SelectValueFromList(string itemToSelect, ListBox list) { ListItems items = list.Items; ListItem item = items.Find( x => x.GetElement(SearchCriteria.ByControlType(ControlType.Text)). GetCurrentPropertyValue(AutomationElement.NameProperty).Equals(itemToSelect)); //Assert.NotNull(item, "The item {0} is not found on the list {1} items found.", itemToSelect, items.Count); item.Click(); }
public void EnterNumber(int number) { LoggerUtil.Log.Info("User needs to enter: " + number); foreach (var digit in number.ToString()) { Button digitButton = new Button(_window, SearchCriteria.ByControlType(ControlType.Button) .AndByClassName("Button") .AndByText(digit.ToString()), "digit button"); digitButton.Click(); } }
List <TextBox> GetTextboxes() { var type = typeof(TextBox); var criteria = SearchCriteria.ByControlType(testControlType: type, framework: WindowsFramework.Wpf); var textboxes = Context.Window.GetMultiple(criteria) .Cast <TextBox>() .ToList() ; return(textboxes); }
private static SearchCriteria FromControlType(string controlType) { switch (controlType) { case "ListItem": return(SearchCriteria.ByControlType(ControlType.ListItem)); default: Debugger.Break(); return(null); } }
private void SelectTab(string automationId) { var tabbedGroup = BarManager().Get(SearchCriteria.ByControlType(ControlType.Tab).AndAutomationId("MainTabbedView")); tabbedGroup.ShouldNotBe(null); var tabToSelect = tabbedGroup.Get <Button>(automationId + "TabButtonId"); tabToSelect.ShouldNotBe(null); tabToSelect.Click(); }
private void OpenFile(string path) { Panel p = manager.MainWindow.Get(SearchCriteria.ByAutomationId("59392")) as Panel; //ищем панель с кнопкой открытия файла p.Get(SearchCriteria.ByControlType((ControlType.MenuItem))).Click(); //кликем по кнопке с открытием List <Window> modalWindows = manager.MainWindow.ModalWindows(); //ловим модальный диалог var combobox = modalWindows.First().Get(SearchCriteria.ByAutomationId("1148")); var textbox = combobox.Get <TextBox>("1148"); textbox.SetValue(path); // вводим путь в поле manager.MainWindow.Get(SearchCriteria.ByText("Открыть")).Click(); //жмем открыть }