Skip to content

Commit

Permalink
Add WebElementExtensions (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
another-one-employee authored Dec 31, 2024
1 parent b0fe287 commit a55a97f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Selenium.WebDriverExtensions/WebElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using OpenQA.Selenium;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Selenium.WebDriverExtensions
{
public static class WebElementExtensions
{
public static void TypeWithDelay(IWebElement element, string text, int delayInMs)
{
foreach (char c in text)
{
element.SendKeys(c.ToString());
Thread.Sleep(delayInMs);
}
}

public static void TypeWithDelay(IWebElement element, string text, TimeSpan delay)
{
foreach (char c in text)
{
element.SendKeys(c.ToString());
Thread.Sleep(delay);
}
}

public static async Task TypeWithDelayAsync(IWebElement element, string text, int delayInMs)
{
foreach (char c in text)
{
element.SendKeys(c.ToString());
await Task.Delay(delayInMs);
}
}

public static async Task TypeWithDelayAsync(IWebElement element, string text, TimeSpan delay)
{
foreach (char c in text)
{
element.SendKeys(c.ToString());
await Task.Delay(delay);
}
}
}
}

0 comments on commit a55a97f

Please sign in to comment.