Esempio n. 1
0
        public AutomationElement[] GetChatListElements()
        {
            MainWindow.SetForeground();
            MainWindow.WaitUntilClickable();

            var chatButton = MainWindow.FindFirstDescendant("聊天", ControlType.Button).AsButton();

            if (chatButton == null)
            {
                throw new Exception("Could not find chat button.");
            }

#if false
            chatButton.DrawHighlight();
            chatButton.Invoke(); // Doesn't work for me.
#else
            chatButton.LeftClick();
#endif

            var chatList = FlaUIHelper.WaitForElement(
                () => MainWindow.FindFirstDescendant("会话", ControlType.List));
            if (chatList == null)
            {
                throw new Exception("Could not find chat list.");
            }

            chatList.DrawHighlight();

            return(chatList.FindAllChildren());
        }
Esempio n. 2
0
        public Tuple <AutomationElement, AutomationElement>[] GetGroupMemberElements(AutomationElement group)
        {
            group.LeftClick();

            var groupPane = FlaUIHelper.WaitForElement(
                () => MainWindow.FindFirstByXPath("/Pane[2]/Pane[2]/Pane[3]/Pane/Pane/Pane/Pane"));

            if (groupPane == null)
            {
                throw new Exception("Could not find group pane.");
            }

            groupPane.DrawHighlight();

            var groupInformationButton = groupPane.FindFirstDescendant("聊天信息", ControlType.Button);

            if (groupInformationButton == null)
            {
                throw new Exception("Could not find group information button.");
            }

            groupInformationButton.LeftClick();

            var groupInformationWindow = FlaUIHelper.WaitForElement(
                () => MainWindow.FindFirstChild("聊天信息", ControlType.Window));

            if (groupInformationWindow == null)
            {
                throw new Exception("Could not find group information window.");
            }

            groupInformationWindow.DrawHighlight();

            var showMoreGroupMembersButton = groupInformationWindow.FindFirstDescendant(
                "查看更多群成员", ControlType.Button);

            if (showMoreGroupMembersButton != null)
            {
                showMoreGroupMembersButton.LeftClick();
            }

            var memberList = FlaUIHelper.WaitForElement(
                () => groupInformationWindow.FindFirstDescendant("聊天成员", ControlType.List));

            if (memberList == null)
            {
                throw new Exception("Could not find member list.");
            }

            memberList.DrawHighlight();

            var groupMemberElements = memberList.FindAllDescendants(
                conditionFactory => conditionFactory.ByControlType(ControlType.Button));

            return(groupMemberElements
                   .Where((e, i) => i % 2 == 0)
                   .Zip(
                       groupMemberElements.Where((e, i) => i % 2 != 0),
                       (a, b) => Tuple.Create(a, b)
                       )
                   .Where((member, i) => !IsAddOrDeleteButton(member, i))
                   .ToArray());
        }