Esempio n. 1
0
        public override IMainWindow GetMainWindow(Application application)
        {
            var window            = application.GetWindow(SearchCriteria.ByFramework(framework.FrameworkId).AndByText(MainWindowTitle()), InitializeOption.NoCache);
            var mainWindowAdapter = new ProxyGenerator().CreateInterfaceProxyWithoutTarget <IMainWindow>(new ForwardIfExistsInterceptor(window));

            return(mainWindowAdapter);
        }
 public void Equals()
 {
     Assert.AreEqual(SearchCriteria.ByAutomationId("foo"), SearchCriteria.ByAutomationId("foo"));
     Assert.AreNotEqual(SearchCriteria.ByText("foo"), SearchCriteria.ByAutomationId("foo"));
     Assert.AreEqual(SearchCriteria.ByFramework(Constants.Win32FrameworkId), SearchCriteria.ByFramework(Constants.Win32FrameworkId));
     Assert.AreNotEqual(SearchCriteria.ByFramework(Constants.WinFormFrameworkId), SearchCriteria.ByFramework(Constants.Win32FrameworkId));
     Assert.AreEqual(SearchCriteria.ByAutomationId("foo").AndByText("bar"), SearchCriteria.ByAutomationId("foo").AndByText("bar"));
     Assert.AreEqual(SearchCriteria.ByText("bar").AndAutomationId("foo"), SearchCriteria.ByAutomationId("foo").AndByText("bar"));
 }
        private SearchCriteria GetSearchCriteria()
        {
            var by = context.Request.QueryString["by"];

            if (string.IsNullOrEmpty(by))
            {
                throw new ParameterMissingException("by");
            }

            switch (by)
            {
            case "automationid":
                var automationId = context.Request.QueryString["1"];
                if (string.IsNullOrEmpty(automationId))
                {
                    throw new ParameterMissingException("automation id", 1);
                }

                return(SearchCriteria.ByAutomationId(automationId));

            case "text":
                var text = context.Request.QueryString["1"];
                if (string.IsNullOrEmpty(text))
                {
                    throw new ParameterMissingException("text");
                }

                return(SearchCriteria.ByText(text));

            case "classname":
                var className = context.Request.QueryString["1"];
                if (string.IsNullOrEmpty(className))
                {
                    throw new ParameterMissingException("class name");
                }

                return(SearchCriteria.ByClassName(className));

            case "framework":
                var framework = context.Request.QueryString["1"];
                if (string.IsNullOrEmpty(framework))
                {
                    throw new ParameterMissingException("framework");
                }

                return(SearchCriteria.ByFramework(framework));

            default:
                throw new InputException("Incorrect value for 'by'");
            }
        }
Esempio n. 4
0
 public void EqualsTests()
 {
     Assert.That(SearchCriteria.ByAutomationId("foo"), Is.EqualTo(SearchCriteria.ByAutomationId("foo")));
     Assert.That(SearchCriteria.ByText("foo"), Is.Not.EqualTo(SearchCriteria.ByAutomationId("foo")));
     Assert.That(SearchCriteria.ByFramework(WindowsFramework.Win32.FrameworkId()), Is.EqualTo(SearchCriteria.ByFramework(WindowsFramework.Win32.FrameworkId())));
     Assert.That(SearchCriteria.ByFramework(WindowsFramework.WinForms.FrameworkId()), Is.Not.EqualTo(SearchCriteria.ByFramework(WindowsFramework.Win32.FrameworkId())));
     Assert.That(SearchCriteria.ByAutomationId("foo").AndByText("bar"), Is.EqualTo(SearchCriteria.ByAutomationId("foo").AndByText("bar")));
     Assert.That(SearchCriteria.ByAutomationId("foo").AndByText("bar"), Is.EqualTo(SearchCriteria.ByText("bar").AndAutomationId("foo")));
     //ByNativePropertyTests...
     Assert.That(SearchCriteria.ByNativeProperty(AutomationObjectIds.NameProperty, "blah"), Is.EqualTo(SearchCriteria.ByNativeProperty(AutomationObjectIds.NameProperty, "blah")));
     Assert.That(SearchCriteria.ByNativeProperty(AutomationObjectIds.NameProperty, "blah"), Is.Not.EqualTo(SearchCriteria.ByNativeProperty(AutomationObjectIds.NameProperty, "blah1")));
     Assert.That(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsControlElementProperty, true), Is.EqualTo(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsControlElementProperty, true)));
     Assert.That(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsControlElementProperty, true), Is.Not.EqualTo(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsControlElementProperty, false)));
     Assert.That(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsControlElementProperty, true), Is.Not.EqualTo(SearchCriteria.ByNativeProperty(AutomationObjectIds.IsDockPatternAvailableProperty, true)));
 }
Esempio n. 5
0
 public void Equals()
 {
     Assert.AreEqual(SearchCriteria.ByAutomationId("foo"), SearchCriteria.ByAutomationId("foo"));
     Assert.AreNotEqual(SearchCriteria.ByText("foo"), SearchCriteria.ByAutomationId("foo"));
     Assert.AreEqual(SearchCriteria.ByFramework(Constants.Win32FrameworkId), SearchCriteria.ByFramework(Constants.Win32FrameworkId));
     Assert.AreNotEqual(SearchCriteria.ByFramework(Constants.WinFormFrameworkId), SearchCriteria.ByFramework(Constants.Win32FrameworkId));
     Assert.AreEqual(SearchCriteria.ByAutomationId("foo").AndByText("bar"), SearchCriteria.ByAutomationId("foo").AndByText("bar"));
     Assert.AreEqual(SearchCriteria.ByText("bar").AndAutomationId("foo"), SearchCriteria.ByAutomationId("foo").AndByText("bar"));
     //ByNativePropertyTests...
     Assert.AreEqual(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "blah"), SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "blah"));
     Assert.AreNotEqual(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "blah"), SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "blah1"));
     Assert.AreEqual(SearchCriteria.ByNativeProperty(AutomationElement.IsControlElementProperty, true), SearchCriteria.ByNativeProperty(AutomationElement.IsControlElementProperty, true));
     Assert.AreNotEqual(SearchCriteria.ByNativeProperty(AutomationElement.IsControlElementProperty, true), SearchCriteria.ByNativeProperty(AutomationElement.IsControlElementProperty, false));
     Assert.AreNotEqual(SearchCriteria.ByNativeProperty(AutomationElement.IsControlElementProperty, true), SearchCriteria.ByNativeProperty(AutomationElement.IsDockPatternAvailableProperty, true));
 }
Esempio n. 6
0
 SearchCriteria Criteria()
 {
     return(SearchCriteria.ByFramework(framework.FrameworkId()).AndByText("MainWindow"));
 }
 public static SearchCriteria SearchByFramework(string framework)
 {
     return(SearchCriteria.ByFramework(framework));
 }