public static string GetTotalPrice() { AutomationElement element = ControlFinder.FindByAutomationId("totalPrice"); string totalprice = element.Current.Name; return(totalprice); }
private List <Order> GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.findChildControlsRecursive(cph); var textBoxList = cf.foundsControls; List <Order> orderList = new List <Order>(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrder = Convert.ToInt32(textBox.Text); if (amountOfOrder > 0) { Drinks aDrinks = drinksGateway.GetDrinksById(int.Parse(textBox.ID)); Order order = new Order(); order.Client = Session["logIn"].ToString(); order.Product = aDrinks.Name; order.Amount = amountOfOrder; order.Price = aDrinks.Price; order.Date = DateTime.Now; order.OrderShipped = false; orderList.Add(order); } } } return(orderList); }
//Returns a list of all orders placed in textboxes private ArrayList GetOrders() { //Get list of Textbox objects in ContentPlaceHolder ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.FindChildControlsRecursive(cph); var textBoxList = cf.FoundControls; //Create orders using data from textfields ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { //Make sure textbox.Text is not null if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); //Generate Order for each textbox which has an order greater than 0 if (amountOfOrders > 0) { Coffee coffee = ConnectionClass.GetCoffeeById(Convert.ToInt32(textBox.ID)); Order order = new Order( Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); //Add order to ArrayList orderList.Add(order); } } } return(orderList); }
public void setControl(bool exist, string control, string type) { if (exist) { try { if (type == "LinkButton") { LinkButton link1 = (LinkButton)ControlFinder.FindControlRecursive(this, control); link1.Visible = true; } } catch (Exception ex) { } } else { try { if (type == "LinkButton") { LinkButton link1 = (LinkButton)ControlFinder.FindControlRecursive(this, control); if (link1 != null) { link1.Visible = false; } } } catch (Exception ex) { } } }
private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.FindControlsRecursive(cph); var textBoxList = cf.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { _Coffee coffee = ConnectionClass.GetCoffeById(Convert.ToInt32(textBox.ID)); Order order = new Order( Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); orderList.Add(order); } } } return(orderList); }
private bool IsMinAge() { if (Config.MinAge > 0) { //find the Date of birth control var cfinder = new ControlFinder<DobPicker>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var vfinder = new ControlFinder<RequiredFieldValidator>(); vfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var dobCtl = cfinder.FoundControls.SingleOrDefault(c => c.ID == "DateOfBirth"); if (dobCtl != null) { if (Convert.ToInt32(Common.GetAgeFromDOB(dobCtl.DOBStr)) < Config.MinAge) { RequiredFieldValidator req = new RequiredFieldValidator { ValidationGroup = CreateUserWizard1.ID, ErrorMessage = String.Format( webResources.lblMinAge, Config.MinAge), IsValid = false }; Page.Validators.Add(req); //req.Visible = false; return false; } } return Convert.ToInt32(Common.GetAgeFromDOB(dobCtl.DOBStr)) > Config.MinAge; } return true; }
public static string GetTicketPrice() { AutomationElement element = ControlFinder.FindByAutomationId("pricePerTicket"); string price = element.Current.Name; return(price); }
private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder <TextBox> cf = new ControlFinder <TextBox>(); cf.FindChildControlsRecursive(cph); var textBoxList = cf.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { TblMovies movies = Mothercode.GetMoviesById(Convert.ToInt32(textBox.ID)); Order order = new Order( Session["New"].ToString(), movies.MovieName, amountOfOrders, movies.TotalPrice, DateTime.Now, false); orderList.Add(order); } } } return(orderList); }
public byte[] GetImage(Guid formId, Guid imageId, int height = 0, int width = 0) { var form = FormRepo.GetForm(formId); var finder = new ControlFinder(form); var image = finder.Find(imageId) as BizImage; if (image == null || image.ImageBytes == null) { return(null); } if (width <= 0 && height <= 0) { return(image.ImageBytes); } using (var ms = new MemoryStream(image.ImageBytes)) { using (var ms2 = new MemoryStream()) { ResizeImage(height, width, ms, ms2); ms2.Position = 0; return(ms2.ToArray()); } } }
public void Login(string LoginValue, string PasswordValue) { string LoginField = "agentName"; string PasswordField = "password"; string OkButton = "okButton"; Actions.SetValue(LoginField, LoginValue); Actions.SetValue(PasswordField, PasswordValue); Actions.Click(OkButton); if (LoginValue != "john" || PasswordValue != "hp") { var error = ControlFinder.FindByClassName("#32770"); Assert.IsTrue(error.Current.IsEnabled); string failed = error.Current.Name; Assert.AreEqual("Login Failed", failed); } else { Thread.Sleep(1000); var johnsmith = ControlFinder.FindByAutomationId("usernameTitle"); Assert.AreEqual("John Smith", johnsmith.Current.Name); } Thread.Sleep(2000); }
public void OrderNumber() { Login("john", "hp"); Thread.Sleep(1000); SpecialActions.SelectSearchOrderTab(); var radio_button = ControlFinder.FindByAutomationId("byNumberRadio"); var order_number = ControlFinder.FindByAutomationId("byNumberWatermark"); bool order_number_selected = order_number.Current.IsEnabled; var selected = radio_button.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; bool is_radio_selected = selected.Current.IsSelected; Assert.AreEqual(is_radio_selected, order_number_selected); Thread.Sleep(1000); Actions.SelectItem("byNumberRadio"); var type = order_number.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; var search = ControlFinder.FindByAutomationId("searchBtn"); Assert.AreEqual(false, search.Current.IsEnabled); type.SetValue("123456"); Assert.AreEqual(true, search.Current.IsEnabled); Thread.Sleep(1000); Actions.Click("searchBtn"); var error_message = ControlFinder.FindByAutomationId("65535"); var error_text = error_message.Current.Name; Assert.AreEqual("Order number does not exist.", error_text); }
public static void SelectSearchOrderTab() { var mainwindow = ControlFinder.FindByClassName("NavigationWindow"); var tabs = mainwindow.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem)); var search_order = tabs.Cast <AutomationElement>().ToList().First(tab => tab.Current.Name.Equals("SEARCH ORDER")); SpecialActions.SelectElementItem(search_order); }
public void ControlFinder_FindControl_ReturnsCorrectControl(Type expectedType, string controlName, string htmlResourceName) { string resourcePath = Path.Combine(_resourcesPath, htmlResourceName); string source = File.ReadAllText(resourcePath); var controlFinder = new ControlFinder(""); var webControl = controlFinder.FindControl(source, controlName); Assert.IsInstanceOf(expectedType, webControl); }
public void Test_ControlFinder_FindButtonControl() { string controlName = "Cancel"; string controlType = "Button"; var htmlResourceName = "Controls.html"; string resourcePath = Path.Combine(_resourcesPath, htmlResourceName); string source = File.ReadAllText(resourcePath); var controlFinder = new ControlFinder(source); BaseControl controlFound = controlFinder.Find(controlName, controlType); }
public static string GetSelection(string automationId) { AutomationElement element = ControlFinder.FindByAutomationId(automationId); SelectionPattern pattern; pattern = element.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern; AutomationElement[] selected = pattern.Current.GetSelection(); string selection = selected[0].Current.Name; return(selection); }
protected static string GetText(System.Windows.Controls.ContentControl npdview, string name) { var d = ControlFinder.FindChildren <FrameworkElement>(npdview).FirstOrDefault(_ => _.Name == name); if (d is System.Windows.Controls.ContentControl) { return(((System.Windows.Controls.ContentControl)d).Content?.ToString()); } if (d is System.Windows.Controls.Primitives.TextBoxBase) { return(((TextBlock)d).Text); } return(null); }
public void AddLinkButtonTwo(ControlCollection cc, string storefrontUrl) { // Add code to page for the next navbar piece Page page = (Page)HttpContext.Current.Handler; string format = "<td class='navBarSeparator'></td><td class='navBarCell'><div class='navBarButton' style='float: left;'><div class='navBarButton-t'><div class='navBarButton-b'><div class='navBarButton-l'><div class='navBarButton-r'><div class='navBarButton-tl'><div class='navBarButton-tr'><div class='navBarButton-bl'><div class='navBarButton-br'><div class='navBarButton-inner'><a class='navBarButton' target='_blank' href='{0}'>{1}</a></div></div></div></div></div></div></div></div></div></div></td>"; if (page.Request.Url.ToString().IndexOf("previesreport.aspx") != -1) { format = format.Replace("navBarButton", "navBarButtonSelected"); } // Add the name for our navbar piece the user specified string text = string.Format(format, storefrontUrl, StorefrontAPI.Storefront.GetValue("ModuleField", _SA_LINK_NAME_TWO, _UNIQUE_NAME)); // Get user specfied link for link two button string linkTwoUrl = Storefront.GetValue("ModuleField", _SA_LINK_TWO_URL, _UNIQUE_NAME); // This variable holds the link two url the user provided from the extension setup page // Log that the text has been set and what it is /* * LMTF.LogMessagesToFile(storeFrontName, LOG_FILENAME1, LOG_FILENAME2, $"|----------------------------------------------------------|"); * LMTF.LogMessagesToFile(storeFrontName, LOG_FILENAME1, LOG_FILENAME2, "AddLinkButton called text: " + text); * if ((string)ModuleData[_SA_DEBUGGING_MODE] == "true") * { * LogMessage($"|----------------------------------------------------------|"); * LogMessage("AddLinkButton called text: " + text); * } */ // Add navbar to correct place in list foreach (Control startingControl in cc) { if (startingControl.ToString().IndexOf("pageheader_ascx") != -1) { Control childControl = ControlFinder.FindChildControl(startingControl, "phLeftSide"); try { childControl.Controls.AddAt(childControl.Controls.Count - 2, new LiteralControl(text)); } catch (Exception ex) { string message = ex.Message; } } if (startingControl.HasControls()) { AddLinkButtonTwo(startingControl.Controls, linkTwoUrl); } } }
protected void CreateUserWizard1CreatedUser(object sender, EventArgs e) { var newMember = Members.GetMember(CreateUserWizard1.UserName); XElement root = _memberFields.Root; var properties = RegHelper.GetProperties(newMember); var fields = root.Elements().Where(a => a.Attribute("Show").Value == "true" && a.Attribute("Group").Value == "Member"); foreach (XElement field in fields) { var prop = properties.SingleOrDefault(p => p.Name == field.Name); Registration attr = (Registration)prop.GetCustomAttributes(false)[0]; switch (attr.Control) { case "Text" : case "LongText": var tfinder = new ControlFinder<TextBox>(); tfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var tinfo = tfinder.FoundControls.ToList(); if (tinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(tinfo.Single(t => t.ID == field.Name).Text, prop.PropertyType), null); break; case "DatePicker" : var dfinder = new ControlFinder<DobPicker>(); dfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var dinfo = dfinder.FoundControls.ToList(); if (dinfo.Any(t => t.ID == field.Name)) { newMember.DateOfBirth = dinfo.Single(t => t.ID == field.Name).DOBStr; newMember.Age = Common.GetAgeFromDOB(newMember.DateOfBirth); } break; case "GenderLookup" : var cfinder = new ControlFinder<GenderDropDownList>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.CreateUserStep.ContentTemplateContainer); var cinfo = cfinder.FoundControls.ToList(); if (cinfo.Any(t => t.ID == field.Name)) newMember.Gender = cinfo.Single(t => t.ID == field.Name).SelectedValue; break; } } newMember.MembersIP = Common.GetIP4Address(); newMember.LastIP = newMember.MembersIP; // Save the profile - must be done since we explicitly created this profile instance Members.SaveMember(newMember); Membership.GetUser(newMember.Username,true); }
// private static void GotoProjectTab(string projectTabName) // { // TabControlTester t = new TabControlTester("_projectTabControl"); // // foreach (TabPage page in t.Properties.TabPages) // { // if (page.Name == projectTabName) // { // t.Properties.SelectedTab = page; // break; // } // } //// t.Properties.SelectedTab = t.Properties.TabPages[projectTabName]; // // Assert.IsNotNull(t.Properties.SelectedTab, "Couldn't find "+projectTabName); // } private void WalkTopLevelTabs() { // for(int i = 0; i<10000;i++) // { // Application.DoEvents(); // } ControlFinder f = new ControlFinder("_areasToolStrip"); ToolStrip toolstrip = (ToolStrip)f.Find(); foreach (ToolStripButton button in toolstrip.Items) { string name = button.Name; ClickToolStripButton(name); } }
public static string GetOrderNumber() { string name = null; var OrderNumber = ControlFinder.FindByAutomationId("orderCompleted"); try { name = OrderNumber.Current.Name; } catch { } String[] words = name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string word = words[1]; return(word); }
public void SetUp() { _window = new Window(); _control = new FakeControl(); _mockHelper = new Mock <IVisualTreeHelper>(); _mockHelper.Setup(p => p.GetChildrenCount(_window)) .Returns(1); _mockHelper.Setup(p => p.GetParent(_control)) .Returns(_window); _mockHelper.Setup(p => p.GetChild(_window, 0)) .Returns(_control); _finder = new ControlFinder(_mockHelper.Object); }
public static void SelectItem(string automationId) { var element = ControlFinder.FindByAutomationId(automationId); SelectionItemPattern pattern; try { pattern = element.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; } catch (InvalidOperationException) { Console.WriteLine("Pattern not supported."); return; } pattern.Select(); }
public ModelMessage AddFormMessage(BizForm form, Guid attrId, string message) { if (form != null) { var finder = new ControlFinder(form); var ctrl = finder.FirstOrDefault( c => c is BizDataControl && ((BizDataControl)c).AttributeDefId == attrId); if (ctrl != null) { return(AddMessage(ctrl.Id, message)); } } return(AddMessage(attrId, message)); }
public static T FindParent <T>(this UIElement control) where T : UIElement { UIElement p = VisualTreeHelper.GetParent(control) as UIElement; if (p != null) { if (p is T) { return(p as T); } else { return(ControlFinder.FindParent <T>(p)); } } return(null); }
public static string GetName(string automationId) { string name = null; var element = ControlFinder.FindByAutomationId(automationId); if (element == null) { throw new Exception("Element is null!"); } try { name = element.Current.Name; } catch { } return(name); }
public static void TableItemSelect(string automationId, int indexToSelect) { var element = ControlFinder.FindByAutomationId(automationId); AutomationElementCollection tableItems = element.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem)); SelectionItemPattern selectPattern; try { AutomationElement itemToSelect = tableItems[indexToSelect]; selectPattern = (SelectionItemPattern)itemToSelect.GetCurrentPattern(SelectionItemPattern.Pattern); selectPattern.Select(); } catch (InvalidOperationException) { Console.WriteLine("Pattern not supported."); return; } }
public ModelMessage AddFormMessage(BizForm form, string name, string message) { if (form != null) { var finder = new ControlFinder(form); var ctrl = finder.FirstOrDefault( c => c is BizDataControl && String.Equals(((BizDataControl)c).AttributeName, name, StringComparison.InvariantCultureIgnoreCase)); if (ctrl != null) { return(AddMessage(ctrl.Id, name, message)); } } return(AddMessage(name, message)); }
public static void SetValue(string automationId, string value) { var element = ControlFinder.FindByAutomationId(automationId); if (element != null) { ValuePattern pattern; try { pattern = element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; } catch (InvalidOperationException) { Console.WriteLine("Pattern not supported."); return; } pattern.SetValue(value); } }
public static void ComboboxSelectItem(string automationId, string item) { var element = ControlFinder.FindByAutomationId(automationId); AutomationElementCollection comboboxItem = element.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.ListItem)); ExpandCollapsePattern pattern; try { pattern = element.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; pattern.Expand(); pattern.Collapse(); AutomationElement listItem = element.FindFirst(TreeScope.Subtree, new PropertyCondition(AutomationElement.NameProperty, item)); SelectionItemPattern selectionItemPattern = listItem.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; selectionItemPattern.Select(); } catch (InvalidOperationException) { Console.WriteLine("Pattern not supported."); return; } }
//Returns a list of all orders placed in textboxes private ArrayList GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder<TextBox> cF = new ControlFinder<TextBox>(); cF.FindChildControlsRecursive(cph); IEnumerable<TextBox> textBoxList = cF.FoundControls; ArrayList orderList = new ArrayList(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrders = Convert.ToInt32(textBox.Text); if (amountOfOrders > 0) { Coffee coffee = ConnectionClass.GetCoffeeByID(Convert.ToInt32(textBox.ID)); Order order = new Order(Session["login"].ToString(), coffee.Name, amountOfOrders, coffee.Price, DateTime.Now, false); orderList.Add(order); } } } return orderList; }
private List<Order> GetOrders() { ContentPlaceHolder cph = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1"); ControlFinder<TextBox> cf = new ControlFinder<TextBox>(); cf.findChildControlsRecursive(cph); var textBoxList = cf.foundsControls; List<Order> orderList = new List<Order>(); foreach (TextBox textBox in textBoxList) { if (textBox.Text != "") { int amountOfOrder = Convert.ToInt32(textBox.Text); if (amountOfOrder > 0) { Drinks aDrinks = drinksGateway.GetDrinksById(int.Parse(textBox.ID)); Order order = new Order(); order.Client = Session["logIn"].ToString(); order.Product = aDrinks.Name; order.Amount = amountOfOrder; order.Price = aDrinks.Price; order.Date = DateTime.Now; order.OrderShipped = false; orderList.Add(order); } } } return orderList; }
protected void SaveOptions(object sender, EventArgs e) { var newMember = Members.GetMember(CreateUserWizard1.UserName); XElement root = _memberFields.Root; var properties = RegHelper.GetProperties(newMember); var fields = root.Elements().Where(a => a.Attribute("Show").Value == "true" && a.Attribute("Group").Value != "Member"); foreach (XElement field in fields) { var prop = properties.SingleOrDefault(p => p.Name == field.Name); Registration attr = (Registration)prop.GetCustomAttributes(false)[0]; switch (attr.Control) { case "Text": case "LongText" : var tfinder = new ControlFinder<TextBox>(); tfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var tinfo = tfinder.FoundControls.ToList(); if (tinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(tinfo.Single(t => t.ID == field.Name).Text, prop.PropertyType), null); break; case "CheckBox" : var cfinder = new ControlFinder<CheckBox>(); cfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var cinfo = cfinder.FoundControls.ToList(); if (cinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(cinfo.Single(t => t.ID == field.Name).Checked, prop.PropertyType), null); break; case "CountryLookup" : var dfinder = new ControlFinder<CountryDropDownList>(); dfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var dinfo = dfinder.FoundControls.ToList(); if (dinfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(dinfo.Single(t => t.ID == field.Name).SelectedValue, prop.PropertyType), null); break; case "TimeZoneLookup" : var tzfinder = new ControlFinder<TimeZoneListBox>(); tzfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var tzinfo = tzfinder.FoundControls.ToList(); if (tzinfo.Any(t => t.ID == field.Name)) { string tZone = tzinfo.Single(t => t.ID == field.Name).SelectedValue; prop.SetValue(newMember, Convert.ChangeType(tZone, prop.PropertyType), null); TimeZoneInfo tzoneInfo = TimeZoneInfo.FindSystemTimeZoneById(tZone); newMember.TimeOffset = tzoneInfo.BaseUtcOffset.TotalHours; } break; case "Lookup": var lfinder = new ControlFinder<DropDownList>(); lfinder.FindChildControlsRecursive(CreateUserWizard1.WizardSteps[2]); var linfo = lfinder.FoundControls.ToList(); if (linfo.Any(t => t.ID == field.Name)) prop.SetValue(newMember, Convert.ChangeType(linfo.Single(t => t.ID == field.Name).SelectedValue, prop.PropertyType), null); break; } } Members.SaveMember(newMember); }