/// <summary> /// construct a Selenium Action Manager with an Automation Engine /// </summary> /// <param name="automation">the Automation Engine</param> public SeleniumActionManager(abt.Automation automation, Browser browser) : base(automation) { switch (browser) { case Browser.Chrome: { OpenQA.Selenium.Chrome.ChromeDriverService service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; WebDriver = new OpenQA.Selenium.Chrome.ChromeDriver(service, new OpenQA.Selenium.Chrome.ChromeOptions()); break; } case Browser.FireFox: WebDriver = new OpenQA.Selenium.Firefox.FirefoxDriver(); break; case Browser.Safari: WebDriver = new OpenQA.Selenium.Safari.SafariDriver(); break; default: WebDriver = new OpenQA.Selenium.IE.InternetExplorerDriver(); break; }; WebDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30)); RegisterAction(new ActionClick(WebDriver)); RegisterAction(new ActionOpenURL(WebDriver)); RegisterAction(new ActionRefresh(WebDriver)); RegisterAction(new ActionGoBack(WebDriver)); }
/// <summary> /// construct an ActionManager with an Automation engine /// </summary> /// <param name="automation">the Automation engine</param> public UIAActionManager(abt.Automation automation) : base(automation) { RegisterAction(new ActionClick()); RegisterAction(new ActionStartProgram()); RegisterAction(new ActionCloseWindow()); WaitTime = new TimeSpan(0, 0, 30); }
/// <summary> /// get an UIA action for the line /// </summary> /// <param name="actLine">the action line</param> /// <returns>the UIA action</returns> public override abt.Action getAction(abt.ActionLine actLine) { Window targetWindow = null; IUIItem targetControl = null; if (!Actions.ContainsKey(actLine.ActionName)) throw new Exception(abt.Constants.Messages.Error_Executing_NoAction); if (actLine.WindowName != null && !Parent.Interfaces.ContainsKey(actLine.WindowName)) throw new Exception(abt.Constants.Messages.Error_Matching_Window_NoDefinition); // search for the target control if (actLine.WindowName != null) targetWindow = FindWindow(Parent.Interfaces[actLine.WindowName].Properties); if (actLine.ControlName != null) targetControl = FindControl(targetWindow, Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]); // prepare the action UIAAction action = Actions[actLine.ActionName] as UIAAction; action.Window = targetWindow; action.Control = targetControl; action.Params = actLine.Arguments; return action; }
/// <summary> /// get a Selenium Action for the line /// </summary> /// <param name="actLine">the action line</param> /// <returns>the Selenium Action</returns> public override abt.Action getAction(abt.ActionLine actLine) { IWebElement targetControl = null; if (!Actions.ContainsKey(actLine.ActionName)) throw new Exception(abt.Constants.Messages.Error_Executing_NoAction); if (actLine.WindowName != null && !CheckWindow(actLine.WindowName)) throw new Exception(abt.Constants.Messages.Error_Matching_Control_NoDefinition); if (actLine.ControlName != null && !Parent.Interfaces[actLine.WindowName].Controls.ContainsKey(actLine.ControlName)) throw new Exception(abt.Constants.Messages.Error_Matching_Control_NoDefinition); if (actLine.WindowName != null && actLine.ControlName != null) targetControl = FindControl(Parent.Interfaces[actLine.WindowName].Controls[actLine.ControlName]); // prepare the action SeleniumAction action = Actions[actLine.ActionName] as SeleniumAction; action.Control = targetControl; action.Params = actLine.Arguments; return action; }