Exemplo n.º 1
0
 /// <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);
             }
         });
     }
 }
Exemplo n.º 2
0
 /// <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();
     });
 }
Exemplo n.º 3
0
 /// <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);
         });
     }
 }
Exemplo n.º 4
0
 /// <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);
         });
     }
 }
Exemplo n.º 5
0
 /// <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);
         });
     }
 }
Exemplo n.º 6
0
 /// <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);
         });
     }
 }
Exemplo n.º 7
0
 /// <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);
         });
     }
 }
Exemplo n.º 8
0
 /// <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);
         });
     }
 }
Exemplo n.º 9
0
 /// <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);
         });
     }
 }
Exemplo n.º 10
0
 /// <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();
         });
     }
 }
Exemplo n.º 11
0
 /// <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);
         });
     }
 }