Skip to content

Commit 238ed1f

Browse files
alenrosdiemol
authored andcommitted
Added C# Wait code examples (#27)
1 parent b9e62d5 commit 238ed1f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

docs_source_files/content/webdriver/waits.nl.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,12 @@ el = WebDriverWait(driver).until(lambda d: return d.find_element_by_tag_name("p"
240240
assert el.text == "Hello from JavaScript!"
241241
{{< / code-panel >}}
242242
{{< code-panel language="csharp" >}}
243-
// We don't have a C# code sample yet - Help us out and raise a PR
244-
{{< / code-panel >}}
243+
using (var driver = new FirefoxDriver())
244+
{
245+
var foo = new WebDriverWait(driver, TimeSpan.FromSeconds(3))
246+
.Until(drv => drv.FindElement(By.Name("q")));
247+
Debug.Assert(foo.Text.Equals("Hello from JavaScript!"));
248+
} {{< / code-panel >}}
245249
{{< code-panel language="ruby" >}}
246250
# We don't have a Ruby code sample yet - Help us out and raise a PR
247251
{{< / code-panel >}}
@@ -293,8 +297,7 @@ new WebDriverWait(driver, 3).until(ExpectedConditions.elementToBeClickable(By.xp
293297
WebDriverWait(driver, timeout=3).until(some_condition)
294298
{{< / code-panel >}}
295299
{{< code-panel language="csharp" >}}
296-
// We don't have a C# code sample yet - Help us out and raise a PR
297-
{{< / code-panel >}}
300+
new WebDriverWait(driver, TimeSpan.FromSeconds(3)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a/h3"))); {{< / code-panel >}}
298301
{{< code-panel language="ruby" >}}
299302
# We don't have a Ruby code sample yet - Help us out and raise a PR
300303
{{< / code-panel >}}
@@ -444,8 +447,16 @@ wait = WebDriverWait(driver, 10, poll_frequency=1, ignored_exceptions=[ElementNo
444447
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div")))
445448
{{< / code-panel >}}
446449
{{< code-panel language="csharp" >}}
447-
// We don't have a C# code sample yet - Help us out and raise a PR
448-
{{< / code-panel >}}
450+
using (var driver = new FirefoxDriver())
451+
{
452+
WebDriverWait wait = new WebDriverWait(driver, timeout: TimeSpan.FromSeconds(30))
453+
{
454+
PollingInterval = TimeSpan.FromSeconds(5),
455+
};
456+
wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
457+
458+
var foo = wait.Until(drv => drv.FindElement(By.Id("foo")));
459+
} {{< / code-panel >}}
449460
{{< code-panel language="ruby" >}}
450461
# We don't have a Ruby code sample yet - Help us out and raise a PR
451462
{{< / code-panel >}}

0 commit comments

Comments
 (0)