Skip to content

Commit 44d6fe9

Browse files
alenrosdiemol
authored andcommitted
Added C# Wait code examples (#28)
1 parent 238ed1f commit 44d6fe9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

docs_source_files/content/webdriver/waits.zh-cn.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ el = WebDriverWait(driver).until(lambda d: return d.find_element_by_tag_name("p"
239239
assert el.text == "Hello from JavaScript!"
240240
{{< / code-panel >}}
241241
{{< code-panel language="csharp" >}}
242-
// We don't have a C# code sample yet - Help us out and raise a PR
243-
{{< / code-panel >}}
242+
using (var driver = new FirefoxDriver())
243+
{
244+
var foo = new WebDriverWait(driver, TimeSpan.FromSeconds(3))
245+
.Until(drv => drv.FindElement(By.Name("q")));
246+
Debug.Assert(foo.Text.Equals("Hello from JavaScript!"));
247+
}
248+
{{< / code-panel >}}
244249
{{< code-panel language="ruby" >}}
245250
# We don't have a Ruby code sample yet - Help us out and raise a PR
246251
{{< / code-panel >}}
@@ -292,8 +297,7 @@ new WebDriverWait(driver, 3).until(ExpectedConditions.elementToBeClickable(By.xp
292297
WebDriverWait(driver, timeout=3).until(some_condition)
293298
{{< / code-panel >}}
294299
{{< code-panel language="csharp" >}}
295-
// We don't have a C# code sample yet - Help us out and raise a PR
296-
{{< / code-panel >}}
300+
new WebDriverWait(driver, TimeSpan.FromSeconds(3)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a/h3"))); {{< / code-panel >}}
297301
{{< code-panel language="ruby" >}}
298302
# We don't have a Ruby code sample yet - Help us out and raise a PR
299303
{{< / code-panel >}}
@@ -443,8 +447,16 @@ wait = WebDriverWait(driver, 10, poll_frequency=1, ignored_exceptions=[ElementNo
443447
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div")))
444448
{{< / code-panel >}}
445449
{{< code-panel language="csharp" >}}
446-
// We don't have a C# code sample yet - Help us out and raise a PR
447-
{{< / 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 >}}
448460
{{< code-panel language="ruby" >}}
449461
# We don't have a Ruby code sample yet - Help us out and raise a PR
450462
{{< / code-panel >}}

0 commit comments

Comments
 (0)