Skip to content

Commit

Permalink
tests: 4x the wait_time in tests
Browse files Browse the repository at this point in the history
Hoping that this will help with the flakiness.

Note: I'm 4x'ing with a maximum value of 30.
  • Loading branch information
fsouza committed Nov 10, 2023
1 parent f8eb4ee commit c502bf0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions tests/is_element_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_is_element_present_by_css_using_a_custom_wait_time(self):
"should is element present by css verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(
self.browser.is_element_present_by_css(".async-element2", wait_time=3),
self.browser.is_element_present_by_css(".async-element2", wait_time=12),
)

def test_is_element_present_by_css_returns_false_if_element_is_not_present(self):
Expand All @@ -31,7 +31,7 @@ def test_is_element_not_present_by_css_returns_false_if_element_is_present(self)
def test_is_element_not_present_by_css_using_a_custom_wait_time(self):
"should is element not present by css verify if element is not present using a custom wait time"
self.assertTrue(
self.browser.is_element_not_present_by_css(".async-element", wait_time=3),
self.browser.is_element_not_present_by_css(".async-element", wait_time=12),
)

def test_is_element_present_by_xpath(self):
Expand All @@ -42,7 +42,7 @@ def test_is_element_present_by_xpath(self):
def test_is_element_present_by_xpath_using_a_custom_wait_time(self):
"should is element present by xpath verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(self.browser.is_element_present_by_xpath("//h5", wait_time=3))
self.assertTrue(self.browser.is_element_present_by_xpath("//h5", wait_time=12))

def test_is_element_present_by_xpath_returns_false_if_element_is_not_present(self):
"should is element present by xpath returns false if element is not present"
Expand All @@ -57,7 +57,7 @@ def test_is_element_not_present_by_xpath_returns_false_if_element_is_present(sel
def test_is_element_not_present_by_xpath_using_a_custom_wait_time(self):
"should is element not present by xpath verify if element is not present using a custom wait time"
self.assertTrue(
self.browser.is_element_not_present_by_xpath("//h4", wait_time=3),
self.browser.is_element_not_present_by_xpath("//h4", wait_time=12),
)

def test_is_element_present_by_tag(self):
Expand All @@ -68,7 +68,7 @@ def test_is_element_present_by_tag(self):
def test_is_element_present_by_tag_using_a_custom_wait_time(self):
"should is element present by tag verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(self.browser.is_element_present_by_tag("h4", wait_time=3))
self.assertTrue(self.browser.is_element_present_by_tag("h4", wait_time=12))

def test_is_element_present_by_tag_returns_false_if_element_is_not_present(self):
"should is element present by tag returns false if element is not present"
Expand All @@ -80,7 +80,7 @@ def test_is_element_not_present_by_tag(self):

def test_is_element_not_present_by_tag_using_a_custom_wait_time(self):
"should is element not present by tag verify if element is not present using a custom wait time"
self.assertTrue(self.browser.is_element_not_present_by_tag("h4", wait_time=3))
self.assertTrue(self.browser.is_element_not_present_by_tag("h4", wait_time=12))

def test_is_element_not_present_by_tag_returns_false_if_element_is_present(self):
"""should is_element_not_present_by_tag returns False if element is present"""
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_is_element_present_by_value_using_a_custom_wait_time(self):
"should is element present by value verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(
self.browser.is_element_present_by_value("async-header-value", wait_time=3),
self.browser.is_element_present_by_value("async-header-value", wait_time=12),
)

def test_is_element_present_by_value_returns_false_if_element_is_not_present(self):
Expand All @@ -131,7 +131,7 @@ def test_is_element_not_present_by_value_using_a_custom_wait_time(self):
self.assertTrue(
self.browser.is_element_not_present_by_value(
"async-header-value",
wait_time=3,
wait_time=12,
),
)

Expand All @@ -142,14 +142,14 @@ def test_is_element_not_present_by_value_returns_false_if_element_is_present(sel
def test_is_element_present_by_id(self):
"should is element present by id verify if element is present"
self.browser.find_by_css(".add-async-element").click()
result = self.browser.is_element_present_by_id("async-header", wait_time=5)
result = self.browser.is_element_present_by_id("async-header", wait_time=20)
assert result

def test_is_element_present_by_id_using_a_custom_wait_time(self):
"should is element present by id verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(
self.browser.is_element_present_by_id("async-header", wait_time=3),
self.browser.is_element_present_by_id("async-header", wait_time=12),
)

def test_is_element_present_by_id_returns_false_if_element_is_not_present(self):
Expand All @@ -163,7 +163,7 @@ def test_is_element_not_present_by_id(self):
def test_is_element_not_present_by_id_using_a_custom_wait_time(self):
"should is element not present by id verify if element is not present using a custom wait time"
self.assertTrue(
self.browser.is_element_not_present_by_id("async-header", wait_time=3),
self.browser.is_element_not_present_by_id("async-header", wait_time=12),
)

def test_is_element_not_present_by_id_returns_false_if_element_is_present(self):
Expand All @@ -181,7 +181,7 @@ def test_is_element_present_by_name_using_a_custom_wait_time(self):
"should is element present by name verify if element is present using a custom wait time"
self.browser.find_by_css(".add-async-element").click()
self.assertTrue(
self.browser.is_element_present_by_name("async-input", wait_time=3),
self.browser.is_element_present_by_name("async-input", wait_time=12),
)

def test_is_element_present_by_name_returns_false_if_element_is_not_present(self):
Expand All @@ -195,7 +195,7 @@ def test_is_element_not_present_by_name(self):
def test_is_element_not_present_by_name_using_a_custom_wait_time(self):
"should is element not present by name verify if element is not present using a custom wait time"
self.assertTrue(
self.browser.is_element_not_present_by_name("async-input", wait_time=3),
self.browser.is_element_not_present_by_name("async-input", wait_time=12),
)

def test_is_element_not_present_by_name_returns_false_if_element_is_present(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/is_text_present.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_is_text_present_and_should_return_false(self):
def test_is_text_present_and_should_wait_time(self):
"should verify if text is present and wait for five seconds"
self.browser.links.find_by_text("FOO").click()
self.assertTrue(self.browser.is_text_present("BAR!", wait_time=5))
self.assertTrue(self.browser.is_text_present("BAR!", wait_time=20))

def test_is_text_not_present(self):
"should verify if text is not present"
Expand All @@ -29,7 +29,7 @@ def test_is_text_not_present_and_should_return_false(self):
def test_is_text_not_present_and_should_wait_time(self):
"should verify if text is not present and wait for five seconds"
self.browser.links.find_by_text("FOO").click()
self.assertTrue(self.browser.is_text_not_present("another text", wait_time=5))
self.assertTrue(self.browser.is_text_not_present("another text", wait_time=20))

def test_is_text_present_no_body(self):
"should work properly (return false) even if there's no body"
Expand Down
10 changes: 5 additions & 5 deletions tests/test_async_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_find_by_css_should_found_an_async_element(get_new_browser, browser_name
browser.visit(EXAMPLE_APP)

browser.find_by_css(".add-async-element").click()
elements = browser.find_by_css(".async-element", wait_time=10)
elements = browser.find_by_css(".async-element", wait_time=30)

assert 1 == len(elements)

Expand All @@ -24,7 +24,7 @@ def test_find_by_xpath_should_found_an_async_element(get_new_browser, browser_na
browser.visit(EXAMPLE_APP)

browser.find_by_css(".add-async-element").click()
elements = browser.find_by_xpath("//h4", wait_time=10)
elements = browser.find_by_xpath("//h4", wait_time=30)

assert 1 == len(elements)

Expand All @@ -35,7 +35,7 @@ def test_find_by_tag_should_found_an_async_element(get_new_browser, browser_name
browser.visit(EXAMPLE_APP)

browser.find_by_css(".add-async-element").click()
elements = browser.find_by_tag("h4", wait_time=10)
elements = browser.find_by_tag("h4", wait_time=30)

assert 1 == len(elements)

Expand All @@ -46,7 +46,7 @@ def test_find_by_id_should_found_an_async_element(get_new_browser, browser_name)
browser.visit(EXAMPLE_APP)

browser.find_by_css(".add-async-element").click()
elements = browser.find_by_id("async-header", wait_time=10)
elements = browser.find_by_id("async-header", wait_time=30)

assert 1 == len(elements)

Expand All @@ -68,6 +68,6 @@ def test_find_by_value_should_found_an_async_element(get_new_browser, browser_na
browser.visit(EXAMPLE_APP)

browser.find_by_css(".add-async-element").click()
elements = browser.find_by_value("async-header-value", wait_time=10)
elements = browser.find_by_value("async-header-value", wait_time=30)

assert 1 == len(elements)
4 changes: 2 additions & 2 deletions tests/test_element_is_visible.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_element_is_visible_custom_wait_time(browser_name, get_new_browser):
browser.visit(EXAMPLE_APP)

browser.find_by_css(".show-invisible-element").click()
assert browser.find_by_css("#invisible").is_visible(wait_time=3)
assert browser.find_by_css("#invisible").is_visible(wait_time=12)


@pytest.mark.parametrize("browser_name", supported_browsers)
Expand Down Expand Up @@ -61,4 +61,4 @@ def test_element_is_not_visible_custom_wait_time(browser_name, get_new_browser):
browser = get_new_browser(browser_name)
browser.visit(EXAMPLE_APP)

assert browser.find_by_css("#invisible").is_not_visible(wait_time=3)
assert browser.find_by_css("#invisible").is_not_visible(wait_time=12)
6 changes: 3 additions & 3 deletions tests/test_mouse_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_mouse_over(browser_name, get_new_browser):
element = browser.find_by_css(".add-element-mouseover")
element.mouse_over()

assert browser.is_element_present_by_id("what-is-your-name", wait_time=5)
assert browser.is_element_present_by_id("what-is-your-name", wait_time=20)

element = browser.find_by_css(".add-element-mouseover")
element.mouse_out()
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_double_click(browser_name, get_new_browser):
button.double_click()

assert browser.find_by_css(".should-be-visible-after-double-click").is_visible(
wait_time=5,
wait_time=20,
)
assert browser.is_element_not_present_by_id("what-is-your-name")

Expand All @@ -80,7 +80,7 @@ def test_right_click(browser_name, get_new_browser):
element.right_click()

time.sleep(2)
result_1 = browser.find_by_text("right clicked", wait_time=5).text
result_1 = browser.find_by_text("right clicked", wait_time=20).text
result_2 = browser.find_by_css(".right-clicable").text

assert result_1 == result_2 == "right clicked"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_webdriver_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_firefox_create_instance_with_extension(request):
browser.visit(EXAMPLE_APP)

elem = browser.find_by_css("body")
elem.is_visible(wait_time=5)
elem.is_visible(wait_time=20)
style = elem._element.get_attribute("style")

assert "border: 5px solid red;" == style
Expand Down

0 comments on commit c502bf0

Please sign in to comment.