Exemplo n.º 1
0
 public WindowSession(ApplicationSession applicationSession, InitializeOption initializeOption)
 {
     this.applicationSession = applicationSession;
     windowItemsMap = WindowItemsMap.Create(initializeOption, RectX.UnlikelyWindowPosition);
     if (windowItemsMap.LoadedFromFile) initializeOption.NonCached();
     this.initializeOption = initializeOption;
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
        }
 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);
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 9
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;
     }
 }
Exemplo n.º 10
0
 public BrowserWindow(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
Exemplo n.º 11
0
 private Desktop(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption,
                 WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     finder = new AutomationElementFinder(automationElement);
 }
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(title, 0);
     return ModalWindow(@do, option, windowSession);
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
0
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     return ModalWindow(() => Finder.FindWindow(title, 0), option, windowSession);
 }
Exemplo n.º 15
0
 public virtual StatusStrip StatusBar(InitializeOption initializeOption)
 {
     var statusStrip = (StatusStrip) Get(SearchCriteria.ByControlType(ControlType.StatusBar));
     statusStrip.Cached = initializeOption;
     statusStrip.Associate(windowSession);
     return statusStrip;
 }
Exemplo n.º 16
0
 public virtual Window Create(AutomationElement automationElement, InitializeOption initializeOption, WindowSession session)
 {
     return new InternetExplorerWindow(automationElement, WindowFactory.Desktop, initializeOption, session);
 }
Exemplo n.º 17
0
 public override WindowSession WindowSession(InitializeOption initializeOption)
 {
     return new NullWindowSession();
 }
Exemplo n.º 18
0
 public virtual WindowSession ModalWindowSession(InitializeOption modalInitializeOption)
 {
     return applicationSession.WindowSession(modalInitializeOption);
 }
Exemplo n.º 19
0
 protected Window(AutomationElement automationElement, InitializeOption initializeOption,
     WindowSession windowSession)
     : base(automationElement, new NullActionListener(), initializeOption, windowSession)
 {
     InitializeWindow();
 }
Exemplo n.º 20
0
 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);
 }
Exemplo n.º 21
0
 protected TestConfiguration(string program, string commandLineArguments)
 {
     this.program = program;
     this.commandLineArguments = commandLineArguments;
     windowInitializeOption = InitializeOption.NoCache;
 }
Exemplo n.º 22
0
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     return ModalWindow(() => Finder.FindWindow(searchCriteria), option, windowSession);
 }
Exemplo n.º 23
0
 public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
 {
     return Create(FindWindowElement(process, title), option, windowSession);
 }
Exemplo n.º 24
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);
 }
Exemplo n.º 25
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);
Exemplo n.º 26
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     return null;
 }
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(searchCriteria);
     return ModalWindow(@do, option, windowSession);
 }
Exemplo n.º 28
0
 public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
 {
     return null;
 }
Exemplo n.º 29
0
 public DummyWindow(AutomationElement automationElement, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, initializeOption, windowSession)
 {
 }
 public InternetExplorerWindow(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }