Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
    public static string GetTotalPrice()
    {
        AutomationElement element    = ControlFinder.FindByAutomationId("totalPrice");
        string            totalprice = element.Current.Name;

        return(totalprice);
    }
Example #4
0
    public static string GetTicketPrice()
    {
        AutomationElement element = ControlFinder.FindByAutomationId("pricePerTicket");
        string            price   = element.Current.Name;

        return(price);
    }
Example #5
0
        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);
        }
Example #6
0
    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);
    }
Example #7
0
        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();
        }
Example #8
0
        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;
            }
        }
Example #9
0
        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);
        }
Example #10
0
        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);
            }
        }
Example #11
0
        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;
            }
        }