Skip to content

Commit

Permalink
Merge pull request #63 from FlaUI/add-windows-extensions-debug-logging
Browse files Browse the repository at this point in the history
Add windows extensions debug logging
  • Loading branch information
aristotelos authored Aug 28, 2024
2 parents 73db943 + 01716db commit 35a97b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/FlaUI.WebDriver/Controllers/ExecuteController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using FlaUI.Core.Input;
using FlaUI.Core.WindowsAPI;
using FlaUI.WebDriver.Models;
using FlaUI.WebDriver.Models;
using FlaUI.WebDriver.Services;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using System.Drawing;
using System.Text.Json;

namespace FlaUI.WebDriver.Controllers
Expand Down
8 changes: 7 additions & 1 deletion src/FlaUI.WebDriver/Services/WindowsExtensionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using FlaUI.Core.WindowsAPI;
using FlaUI.WebDriver.Models;
using System.Drawing;
using System.Runtime.CompilerServices;

namespace FlaUI.WebDriver.Services
{
Expand All @@ -25,10 +24,12 @@ public async Task ExecuteClickScript(Session session, WindowsClickScript action)
{
throw WebDriverResponseException.ElementNotFound(action.ElementId);
}
_logger.LogDebug("Clicking element {ElementId} with mouse button {MouseButton}", action.ElementId, mouseButton);
Mouse.Click(element.BoundingRectangle.Location, mouseButton);
}
else if (action.X.HasValue && action.Y.HasValue)
{
_logger.LogDebug("Clicking point ({X}, {Y}) with mouse button {MouseButton}", action.X.Value, action.Y.Value, mouseButton);
Mouse.Click(new Point { X = action.X.Value, Y = action.Y.Value }, mouseButton);
}
else
Expand All @@ -42,6 +43,7 @@ public async Task ExecuteHoverScript(Session session, WindowsHoverScript action)
{
if (action.StartX.HasValue && action.StartY.HasValue)
{
_logger.LogDebug("Moving mouse to ({X}, {Y})", action.StartX.Value, action.StartY.Value);
Mouse.MoveTo(action.StartX.Value, action.StartY.Value);
}
else if (action.StartElementId != null)
Expand All @@ -51,6 +53,7 @@ public async Task ExecuteHoverScript(Session session, WindowsHoverScript action)
{
throw WebDriverResponseException.ElementNotFound(action.StartElementId);
}
_logger.LogDebug("Moving mouse to element {ElementId}", action.StartElementId);
Mouse.MoveTo(element.BoundingRectangle.Location);
}
else
Expand All @@ -60,11 +63,13 @@ public async Task ExecuteHoverScript(Session session, WindowsHoverScript action)

if (action.DurationMs.HasValue)
{
_logger.LogDebug("Waiting for {DurationMs}ms", action.DurationMs.Value);
await Task.Delay(action.DurationMs.Value);
}

if (action.EndX.HasValue && action.EndY.HasValue)
{
_logger.LogDebug("Moving mouse to ({X}, {Y})", action.EndX.Value, action.EndY.Value);
Mouse.MoveTo(action.EndX.Value, action.EndY.Value);
}
else if (action.EndElementId != null)
Expand All @@ -74,6 +79,7 @@ public async Task ExecuteHoverScript(Session session, WindowsHoverScript action)
{
throw WebDriverResponseException.ElementNotFound(action.EndElementId);
}
_logger.LogDebug("Moving mouse to element {ElementId}", action.EndElementId);
Mouse.MoveTo(element.BoundingRectangle.Location);
}
else
Expand Down

0 comments on commit 35a97b7

Please sign in to comment.