Skip to content

Added C# wait examples #29

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

Merged
merged 2 commits into from
Oct 27, 2019
Merged
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
20 changes: 17 additions & 3 deletions docs_source_files/content/webdriver/waits.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ el = WebDriverWait(driver).until(lambda d: return d.find_element_by_tag_name("p"
assert el.text == "Hello from JavaScript!"
{{< / code-panel >}}
{{< code-panel language="csharp" >}}
// We don't have a C# code sample yet - Help us out and raise a PR
using (var driver = new FirefoxDriver())
{
var foo = new WebDriverWait(driver, TimeSpan.FromSeconds(3))
.Until(drv => drv.FindElement(By.Name("q")));
Debug.Assert(foo.Text.Equals("Hello from JavaScript!"));
}
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# We don't have a Ruby code sample yet - Help us out and raise a PR
Expand Down Expand Up @@ -287,7 +292,7 @@ new WebDriverWait(driver, 3).until(ExpectedConditions.elementToBeClickable(By.xp
WebDriverWait(driver, timeout=3).until(some_condition)
{{< / code-panel >}}
{{< code-panel language="csharp" >}}
// We don't have a C# code sample yet - Help us out and raise a PR
new WebDriverWait(driver, TimeSpan.FromSeconds(3)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a/h3")));
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# We don't have a Ruby code sample yet - Help us out and raise a PR
Expand Down Expand Up @@ -438,7 +443,16 @@ wait = WebDriverWait(driver, 10, poll_frequency=1, ignored_exceptions=[ElementNo
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div")))
{{< / code-panel >}}
{{< code-panel language="csharp" >}}
// We don't have a C# code sample yet - Help us out and raise a PR
using (var driver = new FirefoxDriver())
{
WebDriverWait wait = new WebDriverWait(driver, timeout: TimeSpan.FromSeconds(30))
{
PollingInterval = TimeSpan.FromSeconds(5),
};
wait.IgnoreExceptionTypes(typeof(NoSuchElementException));

var foo = wait.Until(drv => drv.FindElement(By.Id("foo")));
}
{{< / code-panel >}}
{{< code-panel language="ruby" >}}
# We don't have a Ruby code sample yet - Help us out and raise a PR
Expand Down