private static RequestManager InitRequestManager(SessionManager sessionManager, IOverlay overlay) { var context = new DriverContext(); var manager = new RequestManager(sessionManager); var utils = new Utils(); var winUserWrap = new WinUserWrap(); var keyboard = new Keyboard(new KeyboardWrap(), new KeyInteropWrap(), winUserWrap); IMouse mouse = new Mouse(winUserWrap); var wireKeyboard = new WireKeyboard(keyboard); // TODO circular dependency, bad smell? IUIAutomation uiAutomation = new UIAutomation(); IElementFactory elementFactory = new ElementFactory(); ((UIAutomation)uiAutomation).SetElementFactory(elementFactory); ((ElementFactory)elementFactory).SetUIAutomation(uiAutomation); IElementSearcher elementSearcher = new ElementSearcher(uiAutomation, elementFactory); var uacHandler = new UACPromptHandler(uiAutomation, keyboard); var windowFactory = new WindowFactory(uiAutomation, keyboard, winUserWrap); var windowUtils = new WindowUtils(uiAutomation, windowFactory); manager.AddHandler(new ActiveElementHandler(uiAutomation, overlay)); manager.AddHandler(new ButtonUpHandler(mouse)); manager.AddHandler(new ButtonDownHandler(mouse)); manager.AddHandler(new ClearTextHandler(elementFactory)); manager.AddHandler(new ClickElementHandler(mouse, overlay, elementFactory)); manager.AddHandler(new ClickHandler(mouse)); manager.AddHandler(new CloseWindowHandler(windowUtils)); manager.AddHandler(new DeleteSessionHandler(sessionManager)); manager.AddHandler(new DoubleClickHandler(mouse)); manager.AddHandler(new FindElementHandler(uiAutomation, overlay, elementFactory, elementSearcher)); manager.AddHandler(new FindElementsHandler(uiAutomation, overlay, elementFactory, elementSearcher)); manager.AddHandler(new GetElementAttributeHandler(elementFactory)); manager.AddHandler(new GetElementLocationHandler(elementFactory)); manager.AddHandler(new GetElementLocationInViewHandler(elementFactory)); manager.AddHandler(new GetElementSizeHandler(elementFactory)); manager.AddHandler(new GetElementTagNameHandler()); manager.AddHandler(new GetElementTextHandler()); manager.AddHandler(new GetCurrentWindowHandler(uiAutomation)); manager.AddHandler(new GetSourceHandler(uiAutomation)); manager.AddHandler(new GetTitleHandler(uiAutomation)); manager.AddHandler(new GetWindowLocationHandler(windowFactory, windowUtils)); manager.AddHandler(new GetWindowsHandler(windowUtils)); manager.AddHandler(new GetWindowSizeHandler(windowFactory, windowUtils)); manager.AddHandler(new ImplicitWaitHandler()); manager.AddHandler(new IsElementDisplayedHandler()); manager.AddHandler(new IsElementEnabledHandler()); manager.AddHandler(new IsElementSelectedHandler()); manager.AddHandler(new MoveToHandler(mouse, overlay, elementFactory)); manager.AddHandler(new NewSessionHandler(context, sessionManager, uacHandler, utils)); manager.AddHandler(new SameElementHandler()); manager.AddHandler(new ScreenshotHandler()); manager.AddHandler(new SendKeysHandler(wireKeyboard)); manager.AddHandler(new SetElementValueHandler(wireKeyboard, elementFactory)); manager.AddHandler(new SwitchToWindowHandler(uiAutomation, windowFactory, windowUtils)); return manager; }
public Server(RequestManager requestManager) { this.requestManager = requestManager; }