/// <summary> /// Takes a screenshot of the current page. /// </summary> /// <param name="fileName">Name of the file.</param> public void TakeScreenshot(string fileName) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Screenshot", Arguments = new Dictionary <string, dynamic>() { { "fileName", fileName } } }); } else { CurrentActionBucket.Add(() => { if (!string.IsNullOrEmpty(Provider.ScreenshotPath)) { Provider.TakeScreenshot(System.IO.Path.Combine(Provider.ScreenshotPath, fileName)); } else { Provider.TakeScreenshot(fileName); } }); } }
/// <summary> /// Focuses the specified element selector. /// </summary> /// <param name="elementSelector">The element selector.</param> /// <param name="conditions">The conditions.</param> public void Focus(string elementSelector, MatchConditions conditions) { CurrentActionBucket.Add(() => { var field = Provider.GetElement(elementSelector, conditions); field.Focus(); }); }
/// <summary> /// Waits the specified time. /// </summary> /// <param name="timeSpan">The time span.</param> public void Wait(TimeSpan timeSpan) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Wait", Arguments = new Dictionary <string, dynamic>() { { "milliseconds", timeSpan.TotalMilliseconds.ToString() } } }); } else { CurrentActionBucket.Add(() => { Provider.Wait(timeSpan); }); } }
/// <summary> /// Types the specified value using ActionManager.SendString() /// </summary> /// <param name="value">The value.</param> public void Type(string value) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Type", Arguments = new Dictionary <string, dynamic>() { { "value", value } } }); } else { CurrentActionBucket.Add(() => { CommandManager.SendString(value); }); } }
/// <summary> /// Presses the specified keys using ActionManager.SendKeys() /// </summary> /// <param name="keys">The keys.</param> public void Press(string keys) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Press", Arguments = new Dictionary <string, dynamic>() { { "keys", keys } } }); } else { CurrentActionBucket.Add(() => { CommandManager.SendKeys(keys); }); } }
/// <summary> /// Opens the specified page URI. /// </summary> /// <param name="pageUri">The page URI.</param> public void Open(Uri pageUri) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Open", Arguments = new Dictionary <string, dynamic>() { { "URL", pageUri.ToString() } } }); } else { CurrentActionBucket.Add(() => { Provider.Navigate(pageUri); }); } }
/// <summary> /// Navigates the browser the specified direction. /// </summary> /// <param name="direction">The direction.</param> public void Navigate(NavigateDirection direction) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Navigate", Arguments = new Dictionary <string, dynamic>() { { "direction", direction.ToString() } } }); } else { CurrentActionBucket.Add(() => { Provider.Navigate(direction); }); } }
/// <summary> /// Hovers over the specified point (X, Y coordinates). /// </summary> /// <param name="point">The point.</param> public void Hover(API.Point point) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Hover", Arguments = new Dictionary <string, dynamic>() { { "point", string.Format("{0},{1}", point.X, point.Y) } } }); } else { CurrentActionBucket.Add(() => { Provider.HoverPoint(point); }); } }
/// <summary> /// Clicks a point relative to the position of the container from the top left. Useful when pages are centered or oddly positioned. /// </summary> /// <param name="containerSelector">The container selector.</param> /// <param name="point">The point.</param> public void Click(string containerSelector, API.Point point) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Click", Arguments = new Dictionary <string, dynamic>() { { "selector", containerSelector }, { "point", string.Format("{0},{1}", point.X, point.Y) } } }); } else { CurrentActionBucket.Add(() => { Provider.ClickWithin(containerSelector, point); }); } }
/// <summary> /// Hovers over the specified element selector that matches the conditions. /// </summary> /// <param name="elementSelector">The element selector.</param> /// <param name="conditions">The conditions.</param> public void Hover(string elementSelector, MatchConditions conditions) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Hover", Arguments = new Dictionary <string, dynamic>() { { "selector", elementSelector }, { "matchConditions", conditions.ToString() } } }); } else { CurrentActionBucket.Add(() => { var field = Provider.GetElement(elementSelector, conditions); field.Hover(); }); } }
/// <summary> /// Uploads the specified file name. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="fieldSelector">The field selector.</param> /// <param name="offset">The offset.</param> /// <param name="conditions">The conditions.</param> protected void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions) { if (this.EnableRemoteExecution) { this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails() { Name = "Upload", Arguments = new Dictionary <string, dynamic>() { { "selector", fieldSelector }, { "fileName", fileName }, { "offset", string.Format("{0},{1}", offset.X, offset.Y) }, { "matchConditions", conditions.ToString() } } }); } else { CurrentActionBucket.Add(() => { Provider.Upload(fileName, fieldSelector, offset, conditions); }); } }