Пример #1
0
        public string ReadLocalTime()
        {
            string           localTimeText       = "";
            AppiumWebElement worldClockPivotItem = AlarmClockSession.FindElementByAccessibilityId("WorldClockPivotItem");

            if (worldClockPivotItem != null)
            {
                try
                {
                    localTimeText = worldClockPivotItem.FindElementByClassName("ClockCardItem").Text;
                }
                catch (OpenQA.Selenium.NoSuchElementException)
                {
                    // On Windows 10 anniversary edition, the ClockCardItem has been changed to ListViewItem
                    // If the previous item wasn't found, then look for the new one.
                    localTimeText = worldClockPivotItem.FindElementByClassName("ListViewItem").Text;
                }
                var timeStrings = localTimeText.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                foreach (string timeString in timeStrings)
                {
                    // Get the time. E.g. "11:32 AM" from "Local time, Monday, February 22, 2016, 11:32 AM, "
                    if (timeString.Contains(":"))
                    {
                        localTimeText = timeString;
                        break;
                    }
                }
            }

            return(localTimeText);
        }
Пример #2
0
        private string GetListPersonElementText(AndroidAppAccess appAccess, AndroidElement listLElement)
        {
            try
            {
                StringBuilder    textBuilder  = new StringBuilder();
                AppiumWebElement nameLElement = listLElement.FindElementByClassName("android.widget.LinearLayout");
                if (nameLElement != null)
                {
                    AppiumWebElement nameElement = nameLElement.FindElementByClassName("android.widget.TextView");
                    if (nameElement != null)
                    {
                        ReadOnlyCollection <AppiumWebElement> propertyElements = listLElement.FindElementsByClassName("android.widget.TextView");
                        for (int i = 0; i < propertyElements.Count; i++)
                        {
                            textBuilder.AppendLine();
                            textBuilder.Append(propertyElements[i].Text.Trim());
                        }
                        return(textBuilder.ToString());
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                //总是莫名其妙报错
                return(null);
            }
        }
Пример #3
0
        public ITextBox FindComboBox(string accessibleName, out AppiumWebElement comboBoxElement)
        {
            if (Session == null)
            {
                throw new Exception($"Please call method {nameof(Initialize)}, first");
            }

            comboBoxElement = Session.FindElementByAccessibilityId(accessibleName);
            return(TextBoxServices.Create(comboBoxElement.FindElementByClassName(UiClassNames.TextBox)));
        }
Пример #4
0
        public string ReadLocalTime()
        {
            string           localTimeText       = "";
            AppiumWebElement worldClockPivotItem = AlarmClockSession.FindElementByAccessibilityId("WorldClockPivotItem");

            if (worldClockPivotItem != null)
            {
                localTimeText = worldClockPivotItem.FindElementByClassName("ClockCardItem").Text;
                var timeStrings = localTimeText.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (timeStrings.Length >= 5)
                {
                    // Get the time. E.g. "Local time, Monday, February 22, 2016, 11:32 AM, "
                    localTimeText = timeStrings[4];
                }
            }

            return(localTimeText);
        }
Пример #5
0
        public string ReadLocalTime()
        {
            string localTimeText = "";
            AppiumWebElement worldClockPivotItem =
                AlarmClockSession.FindElementByAccessibilityId("WorldClockPivotItem");
            if (worldClockPivotItem != null)
            {
                localTimeText = worldClockPivotItem.FindElementByClassName("ClockCardItem").Text;
                var timeStrings = localTimeText.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);

                foreach (string timeString in timeStrings)
                {
                    // Get the time. E.g. "11:32 AM" from "Local time, Monday, February 22, 2016, 11:32 AM, "
                    if (timeString.Contains(":"))
                    {
                        localTimeText = timeString;
                        break;
                    }
                }
            }

            return localTimeText;
        }
Пример #6
0
        protected override void PopulateItemsOnNavigate(AppiumWebElement propWindow)
        {
            var slider = propWindow.FindElementByClassName("msctls_trackbar32");

            this.OpacitySlider = new SliderMeta(slider, "WindowAlpha", true, NativeMethods.WinConP.PKEY_Console_WindowTransparency);
        }