diff --git a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs index 2935496c..7ac03f17 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Browsing/Models/ElementActionArgs.cs @@ -12,6 +12,10 @@ public class ElementActionArgs public ElementPosition? Position { get; set; } + /// + /// Delay milliseconds before pressing key + /// + public int DelayBeforePressingKey { get; set; } public string? PressKey { get; set; } /// diff --git a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs index 93928af9..f7884beb 100644 --- a/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs +++ b/src/Plugins/BotSharp.Plugin.WebDriver/Drivers/PlaywrightDriver/PlaywrightWebDriver.DoAction.cs @@ -56,6 +56,10 @@ public partial class PlaywrightWebDriver if (action.PressKey != null) { + if (action.DelayBeforePressingKey > 0) + { + await Task.Delay(action.DelayBeforePressingKey); + } await locator.PressAsync(action.PressKey); } } @@ -64,6 +68,10 @@ public partial class PlaywrightWebDriver await locator.PressSequentiallyAsync(action.Content); if (action.PressKey != null) { + if (action.DelayBeforePressingKey > 0) + { + await Task.Delay(action.DelayBeforePressingKey); + } await locator.PressAsync(action.PressKey); } }