BotSharp/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs

34 lines
994 B
C#
Raw Normal View History

2024-03-08 13:17:36 +00:00
namespace BotSharp.Plugin.WebDriver.Drivers.PlaywrightDriver;
public partial class PlaywrightWebDriver
{
public async Task DoAction(MessageInfo message, ElementActionArgs action, BrowserActionResult result)
{
2024-04-09 03:38:56 +00:00
var page = _instance.GetPage(message.ContextId);
2024-03-08 13:17:36 +00:00
ILocator locator = page.Locator(result.Selector);
2024-04-08 15:09:08 +00:00
if (action.Action == BroswerActionEnum.Click)
2024-03-08 13:17:36 +00:00
{
2024-04-16 04:48:22 +00:00
if (action.Position == null)
{
await locator.ClickAsync();
}
else
{
await locator.ClickAsync(new LocatorClickOptions
{
Position = new Position
{
X = action.Position.X,
Y = action.Position.Y
}
});
}
2024-03-08 13:17:36 +00:00
}
2024-04-08 15:09:08 +00:00
else if (action.Action == BroswerActionEnum.InputText)
{
await locator.FillAsync(action.Content);
}
2024-03-08 13:17:36 +00:00
}
}