Beispiel #1
0
        public static WindowItemsMap Create(InitializeOption initializeOption, Point currentWindowPosition)
        {
            if (initializeOption.NoIdentification) return new NullWindowItemsMap();

            string fileLocation = FileLocation(initializeOption);
            if (File.Exists(fileLocation))
            {
                Logger.DebugFormat("[PositionBasedSearch] Loading WindowItemsMap for: {0}, from {1}", initializeOption.Identifier, fileLocation);
                WindowItemsMap windowItemsMap = null;
                try
                {
                    using (var fileStream = CreateFileStream(fileLocation))
                    {
                        windowItemsMap = (WindowItemsMap)CreateDataContractSerializer().ReadObject(fileStream);
                    }
                }
                catch (Exception ex)
                {
                    Logger.DebugFormat("[PositionBasedSearch] Loading WindowItemsMap FAILED for: {0}, Error: {1}", initializeOption.Identifier, ex.Message);
                    Logger.DebugFormat("[PositionBasedSearch] Deleting WindowItemsMap for: {0}", initializeOption.Identifier);
                    try { File.Delete(fileLocation); }
                    catch (IOException) { }
                }

                if (windowItemsMap != null)
                {
                    windowItemsMap.currentWindowPosition = currentWindowPosition;
                    windowItemsMap.loadedFromFile = true;
                    return windowItemsMap;
                }
            }

            Logger.DebugFormat("[PositionBasedSearch] Creating new WindowItemsMap for: {0}", initializeOption.Identifier);
            return new WindowItemsMap(fileLocation, currentWindowPosition);
        }
 public WindowSession(ApplicationSession applicationSession, InitializeOption initializeOption)
 {
     this.applicationSession = applicationSession;
     windowItemsMap = WindowItemsMap.Create(initializeOption, RectX.UnlikelyWindowPosition);
     if (windowItemsMap.LoadedFromFile) initializeOption.NonCached();
     this.initializeOption = initializeOption;
 }
Beispiel #3
0
 public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
 {
     string message =
         string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
     AutomationElement element = WaitTillFound(() => finder.FindWindow(searchCriteria, process.Id), message);
     return Create(element, option, windowSession);
 }
 public virtual MainScreen SetUp(InitializeOption initializeOption)
 {
     WinFormTestConfiguration configuration = new WinFormTestConfiguration(string.Empty);
     application = configuration.Launch();
     ScreenRepository screenRepository = new ScreenRepository(application.ApplicationSession);
     mainScreen = screenRepository.Get<MainScreen>("Form1", initializeOption);
     return mainScreen;
 }
 private Window ModalWindow(Clock.Do find, InitializeOption option, WindowSession windowSession)
 {
     var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout);
     Clock.Matched matched = obj => obj != null;
     Clock.Expired expired = () => null;
     var automationElement = (AutomationElement) clock.Perform(find, matched, expired);
     return automationElement == null ? null: Create(automationElement, option, windowSession);
 }
        public virtual WindowSession WindowSession(InitializeOption initializeOption)
        {
            if (initializeOption.Identifier == null) return new NullWindowSession();

            WindowSession windowSession;
            if (windowSessions.TryGetValue(initializeOption.Identifier, out windowSession)) return windowSession;

            windowSession = new WindowSession(this, initializeOption);
            windowSessions.Add(initializeOption.Identifier, windowSession);
            return windowSession;
        }
        internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
        {
            SpecializedWindowFactory specializedWindowFactory = specializedWindowFactories.Find(factory => factory.DoesSpecializedThis(element));
            if (specializedWindowFactory != null)
            {
                return specializedWindowFactory.Create(element, option, windowSession);
            }

            var windowsFramework = new WindowsFramework(element.Current.FrameworkId);
            if (windowsFramework.WinForm) return new WinFormWindow(element, option, windowSession);
            if (windowsFramework.WPF) return new WPFWindow(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.Win32) return new Win32Window(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.UIAutomationBug) return null;
            throw new UIItemSearchException(string.Format("{0} is not supported yet.", windowsFramework));
        }
Beispiel #8
0
 public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
     WindowSession windowSession)
 {
     var windowFinder = new AutomationElementFinder(parentWindowElement);
     try
     {
         AutomationElement modalWindowElement = WaitTillFound(delegate
                                                                  {
                                                                      AutomationElement windowElement = windowFinder.FindWindow(title, process.Id) ??
                                                                                                        finder.FindWindow(title, process.Id);
                                                                      return windowElement;
                                                                  }, "Could not find modal window with title: " + title);
         return Create(modalWindowElement, option, windowSession);
     }
     catch (UIActionException e)
     {
         WhiteLogger.Instance.Debug(e.ToString());
         return null;
     }
 }
Beispiel #9
0
 public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
 {
     return null;
 }
Beispiel #10
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     return null;
 }
Beispiel #11
0
 public DummyWindow(AutomationElement automationElement, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, initializeOption, windowSession)
 {
 }
Beispiel #12
0
 private static Window ModalWindow(Func<AutomationElement> find, InitializeOption option, WindowSession windowSession)
 {
     var automationElement = Retry.For(find, e => e == null, CoreAppXmlConfiguration.Instance.BusyTimeout());
     return automationElement == null ? null: Create(automationElement, option, windowSession);
 }
 public InternetExplorerWindow(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
Beispiel #14
0
 public virtual Window FindWindow(Process process, Predicate<string> match, InitializeOption initializeOption, WindowSession windowSession)
 {
     string message = string.Format("Could not find window matching condition. ProcessName: {0}, ProcessId: {1}, MatchingConditionMethod: {2}, MatchingConditionTarget: {3}", process.ProcessName, process.Id, match.Method, match.Target);
     AutomationElement foundElement = WaitTillFound(() => FindWindowElement(process, match), message);
     return Create(foundElement, initializeOption, windowSession);
 }
 public virtual Window FindWindow(Process process, Predicate<string> match, InitializeOption initializeOption, WindowSession windowSession)
 {
     AutomationElement foundElement =
         WaitTillFound(() => FindWindowElement(process, match), "Could not find window matching condition");
     return Create(foundElement, initializeOption, windowSession);
 }
 public virtual Window Create(AutomationElement automationElement, InitializeOption initializeOption, WindowSession session)
 {
     return new InternetExplorerWindow(automationElement, WindowFactory.Desktop, initializeOption, session);
 }
 public override WindowSession WindowSession(InitializeOption initializeOption)
 {
     return new NullWindowSession();
 }
 public virtual WindowSession ModalWindowSession(InitializeOption modalInitializeOption)
 {
     return applicationSession.WindowSession(modalInitializeOption);
 }
Beispiel #19
0
 public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
 {
     return(Create(FindWindowElement(process, title), option, windowSession));
 }
Beispiel #20
0
 public virtual StatusStrip StatusBar(InitializeOption initializeOption)
 {
     var statusStrip = (StatusStrip) Get(SearchCriteria.ByControlType(ControlType.StatusBar));
     statusStrip.Cached = initializeOption;
     statusStrip.Associate(windowSession);
     return statusStrip;
 }
Beispiel #21
0
 private Desktop(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption,
                 WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     finder = new AutomationElementFinder(automationElement);
 }
Beispiel #22
0
 public BrowserWindow(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
Beispiel #23
0
 public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
 {
     var windowFinder = new AutomationElementFinder(parentWindowElement);
     try
     {
         AutomationElement modalWindowElement = WaitTillFound(() =>
         {
             AutomationElement windowElement = windowFinder.FindWindow(searchCriteria) ??
                 Finder.FindWindow(searchCriteria);
             return windowElement;
         }, "Could not find modal window with SearchCriteria: " + searchCriteria);
         return Create(modalWindowElement, option, windowSession);
     }
     catch (UIActionException e)
     {
         logger.Debug(e.ToString());
         return null;
     }
 }
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(title, 0);
     return ModalWindow(@do, option, windowSession);
 }
 protected TestConfiguration(string program, string commandLineArguments)
 {
     this.program = program;
     this.commandLineArguments = commandLineArguments;
     windowInitializeOption = InitializeOption.NoCache;
 }
Beispiel #26
0
 /// <summary>
 /// Get the modal window launched by this window.
 /// </summary>
 /// <param name="searchCriteria">Search Criteria to use to find a window</param>
 /// <param name="option">Newly created window would be initialized using this option</param>
 /// <returns></returns>
 public abstract Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option);
Beispiel #27
0
 public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
 {
     return Create(FindWindowElement(process, title), option, windowSession);
 }
Beispiel #28
0
 protected Window(AutomationElement automationElement, InitializeOption initializeOption,
     WindowSession windowSession)
     : base(automationElement, new NullActionListener(), initializeOption, windowSession)
 {
     InitializeWindow();
 }
Beispiel #29
0
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(searchCriteria);
     return(ModalWindow(@do, option, windowSession));
 }
Beispiel #30
0
        public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
        {
            Clock.Do find    = () => finder.FindWindow(searchCriteria, process.Id);
            string   message =
                string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
            AutomationElement element = WaitTillFound(find, message);

            return(Create(element, option, windowSession));
        }
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(searchCriteria);
     return ModalWindow(@do, option, windowSession);
 }
Beispiel #32
0
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     return ModalWindow(() => Finder.FindWindow(title, 0), option, windowSession);
 }
Beispiel #33
0
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     return ModalWindow(() => Finder.FindWindow(searchCriteria), option, windowSession);
 }
Beispiel #34
0
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(title, 0);
     return(ModalWindow(@do, option, windowSession));
 }