Skip to content

[dotnet] Add WebDriverWait constructor for specifying a sleep interval without a clock #15838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/src/support/UI/PopupWindowFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public string Invoke(Action popupMethod)

ReadOnlyCollection<string> existingHandles = this.driver.WindowHandles;
popupMethod();
WebDriverWait wait = new WebDriverWait(SystemClock.Instance, this.driver, this.timeout, this.sleepInterval);
var wait = new WebDriverWait(this.driver, this.timeout, this.sleepInterval);
string popupHandle = wait.Until(driver =>
{
ReadOnlyCollection<string> newHandles = driver.WindowHandles;
Expand Down
12 changes: 12 additions & 0 deletions dotnet/src/webdriver/Support/WebDriverWait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,17 @@ public WebDriverWait(IClock clock, IWebDriver driver, TimeSpan timeout, TimeSpan
this.IgnoreExceptionTypes(typeof(NotFoundException));
}

/// <summary>
/// Initializes a new instance of the <see cref="WebDriverWait"/> class.
/// </summary>
/// <param name="driver">The WebDriver instance used to wait.</param>
/// <param name="timeout">The timeout value indicating how long to wait for the condition.</param>
/// <param name="sleepInterval">A <see cref="TimeSpan"/> value indicating how often to check for the condition to be true.</param>
/// <exception cref="ArgumentNullException">If <paramref name="driver"/> is <see langword="null"/>.</exception>
public WebDriverWait(IWebDriver driver, TimeSpan timeout, TimeSpan sleepInterval)
: this(SystemClock.Instance, driver, timeout, DefaultSleepTimeout)
{
}

private static TimeSpan DefaultSleepTimeout => TimeSpan.FromMilliseconds(500);
}