Skip to content

Commit

Permalink
fix waits
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 2, 2023
1 parent 8f83ae4 commit 175f424
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 46 deletions.
7 changes: 4 additions & 3 deletions examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void Explicit()
{
driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html";
IWebElement revealed = driver.FindElement(By.Id("revealed"));
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2));

driver.FindElement(By.Id("reveal")).Click();

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2));
wait.Until(d => revealed.Displayed);

revealed.SendKeys("Displayed");
Expand All @@ -65,13 +65,14 @@ public void ExplicitOptions()
{
driver.Url = "https://www.selenium.dev/selenium/web/dynamic.html";
IWebElement revealed = driver.FindElement(By.Id("revealed"));
driver.FindElement(By.Id("reveal")).Click();

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(2))
{
PollingInterval = TimeSpan.FromMilliseconds(300),
};
wait.IgnoreExceptionTypes(typeof(ElementNotInteractableException));

driver.FindElement(By.Id("reveal")).Click();
wait.Until(d => {
revealed.SendKeys("Displayed");
return true;
Expand Down
8 changes: 4 additions & 4 deletions examples/python/tests/waits/test_waits.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def test_implicit(driver):
def test_explicit(driver):
driver.get('https://www.selenium.dev/selenium/web/dynamic.html')
revealed = driver.find_element(By.ID, "revealed")
wait = WebDriverWait(driver, timeout=2)

driver.find_element(By.ID, "reveal").click()

wait = WebDriverWait(driver, timeout=2)
wait.until(lambda d : revealed.is_displayed())

revealed.send_keys("Displayed")
Expand All @@ -48,10 +48,10 @@ def test_explicit(driver):
def test_explicit_options(driver):
driver.get('https://www.selenium.dev/selenium/web/dynamic.html')
revealed = driver.find_element(By.ID, "revealed")
driver.find_element(By.ID, "reveal").click()

errors = [NoSuchElementException, ElementNotInteractableException]
wait = WebDriverWait(driver, timeout=2, poll_frequency=.2, ignored_exceptions=errors)

driver.find_element(By.ID, "reveal").click()
wait.until(lambda d : revealed.send_keys("Displayed") or True)

assert revealed.get_property("value") == "Displayed"
7 changes: 4 additions & 3 deletions examples/ruby/spec/waits/waits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
it 'explicit' do
driver.get 'https://www.selenium.dev/selenium/web/dynamic.html'
revealed = driver.find_element(id: 'revealed')
wait = Selenium::WebDriver::Wait.new

driver.find_element(id: 'reveal').click

wait = Selenium::WebDriver::Wait.new
wait.until { revealed.displayed? }

revealed.send_keys('Displayed')
Expand All @@ -49,13 +49,14 @@
it 'options with explicit' do
driver.get 'https://www.selenium.dev/selenium/web/dynamic.html'
revealed = driver.find_element(id: 'revealed')
driver.find_element(id: 'reveal').click

errors = [Selenium::WebDriver::Error::NoSuchElementError,
Selenium::WebDriver::Error::ElementNotInteractableError]
wait = Selenium::WebDriver::Wait.new(timeout: 2,
interval: 0.3,
ignore: errors)

driver.find_element(id: 'reveal').click
wait.until { revealed.send_keys('Displayed') || true }

expect(revealed.property(:value)).to eq('Displayed')
Expand Down
18 changes: 9 additions & 9 deletions website_and_docs/content/documentation/webdriver/waits.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Solving our example with an implicit wait looks like this:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L50" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27-L31" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39-L44" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28-L32" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="examples/javascript/test/waits/waits.spec.js#L37-L41" >}}
Expand Down Expand Up @@ -105,13 +105,13 @@ This example shows the condition being waited for as a _lambda_. Java also suppo
{{% tab header="Python" %}}
This example shows the condition being waited for as a _lambda_. Python also supports
[Expected Conditions]({{< ref "support_features/expected_conditions" >}})
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L38-L44" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L41-L42" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L53-L59" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L56-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L39-L45" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L42-L43" >}}
{{< /tab >}}
{{% tab header="JavaScript" %}}
JavaScript also supports [Expected Conditions]({{< ref "support_features/expected_conditions" >}})
Expand Down Expand Up @@ -142,13 +142,13 @@ The easiest way to customize Waits in Java is to use the `FluentWait` class:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L82-L92" >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L50-L55" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L53-L55" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L67-L78" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L70-L79" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L51-L59" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L54-L60" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
18 changes: 9 additions & 9 deletions website_and_docs/content/documentation/webdriver/waits.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Solving our example with an implicit wait looks like this:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L50" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27-L31" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39-L44" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28-L32" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="examples/javascript/test/waits/waits.spec.js#L37-L41" >}}
Expand Down Expand Up @@ -105,13 +105,13 @@ This example shows the condition being waited for as a _lambda_. Java also suppo
{{% tab header="Python" %}}
This example shows the condition being waited for as a _lambda_. Python also supports
[Expected Conditions]({{< ref "support_features/expected_conditions" >}})
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L38-L44" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L41-L42" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L53-L59" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L56-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L39-L45" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L42-L43" >}}
{{< /tab >}}
{{% tab header="JavaScript" %}}
JavaScript also supports [Expected Conditions]({{< ref "support_features/expected_conditions" >}})
Expand Down Expand Up @@ -142,13 +142,13 @@ The easiest way to customize Waits in Java is to use the `FluentWait` class:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L82-L92" >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L50-L55" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L53-L55" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L67-L78" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L70-L79" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L51-L59" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L54-L60" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
18 changes: 9 additions & 9 deletions website_and_docs/content/documentation/webdriver/waits.pt-br.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Solving our example with an implicit wait looks like this:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L50" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27-L31" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39-L44" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28-L32" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="examples/javascript/test/waits/waits.spec.js#L37-L41" >}}
Expand Down Expand Up @@ -105,13 +105,13 @@ This example shows the condition being waited for as a _lambda_. Java also suppo
{{% tab header="Python" %}}
This example shows the condition being waited for as a _lambda_. Python also supports
[Expected Conditions]({{< ref "support_features/expected_conditions" >}})
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L38-L44" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L41-L42" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L53-L59" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L56-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L39-L45" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L42-L43" >}}
{{< /tab >}}
{{% tab header="JavaScript" %}}
JavaScript also supports [Expected Conditions]({{< ref "support_features/expected_conditions" >}})
Expand Down Expand Up @@ -142,13 +142,13 @@ The easiest way to customize Waits in Java is to use the `FluentWait` class:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L82-L92" >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L50-L55" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L53-L55" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L67-L78" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L70-L79" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L51-L59" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L54-L60" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down
18 changes: 9 additions & 9 deletions website_and_docs/content/documentation/webdriver/waits.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Solving our example with an implicit wait looks like this:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L50" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27-L31" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L27" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39-L44" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L39" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28-L32" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L28" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< gh-codeblock path="examples/javascript/test/waits/waits.spec.js#L37-L41" >}}
Expand Down Expand Up @@ -105,13 +105,13 @@ This example shows the condition being waited for as a _lambda_. Java also suppo
{{% tab header="Python" %}}
This example shows the condition being waited for as a _lambda_. Python also supports
[Expected Conditions]({{< ref "support_features/expected_conditions" >}})
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L38-L44" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L41-L42" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L53-L59" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L56-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L39-L45" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L42-L43" >}}
{{< /tab >}}
{{% tab header="JavaScript" %}}
JavaScript also supports [Expected Conditions]({{< ref "support_features/expected_conditions" >}})
Expand Down Expand Up @@ -142,13 +142,13 @@ The easiest way to customize Waits in Java is to use the `FluentWait` class:
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/waits/WaitsTest.java#L82-L92" >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L50-L55" >}}
{{< gh-codeblock path="examples/python/tests/waits/test_waits.py#L53-L55" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L67-L78" >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Waits/WaitsTest.cs#L70-L79" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L51-L59" >}}
{{< gh-codeblock path="examples/ruby/spec/waits/waits_spec.rb#L54-L60" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down

0 comments on commit 175f424

Please sign in to comment.