-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0fe287
commit a55a97f
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |