示例#1
0
 public SilverlightDocument(AutomationElement automationElement, BrowserWindow actionListener,
                            InitializeOption initializeOption,
                            WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     ieWindow = actionListener;
 }
示例#2
0
 public WindowSession(ApplicationSession applicationSession, InitializeOption initializeOption)
 {
     this.applicationSession = applicationSession;
     windowItemsMap = WindowItemsMap.Create(initializeOption, RectX.UnlikelyWindowPosition);
     if (windowItemsMap.LoadedFromFile) initializeOption.NonCached();
     this.initializeOption = initializeOption;
 }
示例#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);
        }
示例#4
0
 public virtual MainScreen SetUp(InitializeOption initializeOption)
 {
     application = new WinformsTestConfiguration().LaunchApplication();
     var screenRepository = new ScreenRepository(application.ApplicationSession);
     mainScreen = screenRepository.Get<MainScreen>("Form1", initializeOption);
     return mainScreen;
 }
示例#5
0
 public virtual MainScreen SetUp(InitializeOption initializeOption)
 {
     application = new WinformsTestConfiguration().LaunchApplication();
     var screenRepository = new ScreenRepository(application.ApplicationSession);
     mainScreen = screenRepository.Get<MainScreen>("MainWindow", initializeOption);
     //mainScreen.Tabs[0].SelectTabPage(2);
     return mainScreen;
 }
示例#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;
        }
示例#7
0
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
        {
            SpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element));
            if (specializedWindowFactory != null)
            {
                return specializedWindowFactory.Create(element, option, windowSession);
            }

            var windowsFramework = WindowsFrameworkExtensions.FromFrameworkId(element.Current.FrameworkId);
            if (windowsFramework == WindowsFramework.WinForms) return new WinFormWindow(element, option, windowSession);
            if (windowsFramework == WindowsFramework.Wpf) return new WPFWindow(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework == WindowsFramework.Win32) return new Win32Window(element, WindowFactory.Desktop, option, windowSession);
            throw new UIItemSearchException(string.Format("{0} is not supported yet.", windowsFramework));
        }
示例#8
0
 /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
 public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
 {
     var message = string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, ", after waiting for 30 seconds");
     var element = WaitTillFound(() => Finder.FindWindow(title, process.Id), message);
     return Create(element, option, windowSession);
 }
示例#9
0
文件: Window.cs 项目: spider09/White
 protected Window(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     InitializeWindow();
     minOpenTime = Task.Factory.StartNew(() => Thread.Sleep(500));
 }
示例#10
0
 public virtual Window Create(AutomationElement automationElement, InitializeOption initializeOption, WindowSession session)
 {
     return new FirefoxWindow(automationElement, WindowFactory.Desktop, initializeOption, session);
 }
示例#11
0
 public virtual WindowSession ModalWindowSession(InitializeOption modalInitializeOption)
 {
     return applicationSession.WindowSession(modalInitializeOption);
 }
示例#12
0
 /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
 public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
 {
     var windowFinder = new AutomationElementFinder(parentWindowElement);
     var message = "Could not find modal window with SearchCriteria: " + searchCriteria;
     var modalWindowElement = WaitTillFound(() => FindModalWindowElement(searchCriteria, windowFinder), message);
     return Create(modalWindowElement, option, windowSession);
 }
示例#13
0
 public DummyWindow(AutomationElement automationElement, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, initializeOption, windowSession) {}
示例#14
0
 public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
 {
     return null;
 }
示例#15
0
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     var message = "Could not find modal window with SearchCriteria: " + searchCriteria;
     var modalWindowElement = WaitTillFound(() => Finder.FindWindow(searchCriteria), message);
     return Create(modalWindowElement, option, windowSession);
 }
示例#16
0
 /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
 public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
 {
     var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
     var element = WaitTillFound(() => Finder.FindWindow(searchCriteria, process.Id), message);
     return Create(element, option, windowSession);
 }
示例#17
0
文件: Desktop.cs 项目: EDOlsson/White
 private Desktop(AutomationElement automationElement, IActionListener actionListener, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     finder = new AutomationElementFinder(automationElement);
 }
示例#18
0
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     var message = "Could not find modal window with title: " + title;
     var modalWindowElement = WaitTillFound(() => Finder.FindWindow(title, 0), message);
     return Create(modalWindowElement, option, windowSession);
 }
示例#19
0
 public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
 {
     throw new NotSupportedException();
 }
示例#20
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     throw new NotSupportedException();
 }
示例#21
0
 public override WindowSession WindowSession(InitializeOption initializeOption)
 {
     return new NullWindowSession();
 }
示例#22
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     var childWindow = Get<Window>(SearchCriteria.ByText(title));
     return childWindow;
 }
示例#23
0
文件: Window.cs 项目: spider09/White
 /// <summary>
 /// Get the modal window launched by this window.
 /// </summary>
 /// <param name="title">Title of the modal window</param>
 /// <param name="option">Newly created window would be initialized using this option</param>
 /// <returns></returns>
 public abstract Window ModalWindow(string title, InitializeOption option);
示例#24
0
 public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
 {
     var childWindow = Get<Window>(searchCriteria);
     return childWindow;
 }
示例#25
0
文件: Window.cs 项目: spider09/White
 /// <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);
示例#26
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     return null;
 }
示例#27
0
文件: Window.cs 项目: spider09/White
 public virtual StatusStrip StatusBar(InitializeOption initializeOption)
 {
     var statusStrip = (StatusStrip)Get(SearchCriteria.ByControlType(ControlType.StatusBar));
     statusStrip.Cached = initializeOption;
     statusStrip.Associate(WindowSession);
     return statusStrip;
 }
示例#28
0
 /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
 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);
     var foundElement = WaitTillFound(() => FindWindowElement(process, match), message);
     return Create(foundElement, initializeOption, windowSession);
 }
示例#29
0
文件: Window.cs 项目: spider09/White
 protected Window(AutomationElement automationElement, InitializeOption initializeOption, WindowSession windowSession)
     : this(automationElement, new NullActionListener(), initializeOption, windowSession)
 {
 }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
        {
            var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
            var element = WaitTillFound(() => Finder.FindWindow(searchCriteria, process.Id), message);

            return(Create(element, option, windowSession));
        }
示例#31
0
 /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
 public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
     WindowSession windowSession)
 {
     var windowFinder = new AutomationElementFinder(parentWindowElement);
     var message = "Could not find modal window with title: " + title;
     var modalWindowElement = WaitTillFound(() => FindModalWindowElement(title, process, windowFinder), message);
     return Create(modalWindowElement, option, windowSession);
 }