From c502bf09d355d33a9f4cf65f8a19fe094d104ade Mon Sep 17 00:00:00 2001 From: francisco souza <108725+fsouza@users.noreply.github.com> Date: Thu, 9 Nov 2023 23:18:26 -0500 Subject: [PATCH] tests: 4x the `wait_time` in tests Hoping that this will help with the flakiness. Note: I'm 4x'ing with a maximum value of 30. --- tests/is_element_present.py | 26 +++++++++++++------------- tests/is_text_present.py | 4 ++-- tests/test_async_finder.py | 10 +++++----- tests/test_element_is_visible.py | 4 ++-- tests/test_mouse_interaction.py | 6 +++--- tests/test_webdriver_firefox.py | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/is_element_present.py b/tests/is_element_present.py index 2ff897f66..fece9ad52 100644 --- a/tests/is_element_present.py +++ b/tests/is_element_present.py @@ -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): @@ -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): @@ -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" @@ -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): @@ -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" @@ -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""" @@ -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): @@ -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, ), ) @@ -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): @@ -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): @@ -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): @@ -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): diff --git a/tests/is_text_present.py b/tests/is_text_present.py index c12de3e11..6042f9356 100644 --- a/tests/is_text_present.py +++ b/tests/is_text_present.py @@ -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" @@ -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" diff --git a/tests/test_async_finder.py b/tests/test_async_finder.py index 215584a46..5ac7a9c75 100644 --- a/tests/test_async_finder.py +++ b/tests/test_async_finder.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/tests/test_element_is_visible.py b/tests/test_element_is_visible.py index 1f82dbdd1..7d72c0494 100644 --- a/tests/test_element_is_visible.py +++ b/tests/test_element_is_visible.py @@ -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) @@ -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) diff --git a/tests/test_mouse_interaction.py b/tests/test_mouse_interaction.py index 82ec206e2..ccbc85b48 100644 --- a/tests/test_mouse_interaction.py +++ b/tests/test_mouse_interaction.py @@ -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() @@ -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") @@ -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" diff --git a/tests/test_webdriver_firefox.py b/tests/test_webdriver_firefox.py index 440fdefd8..47ec59449 100644 --- a/tests/test_webdriver_firefox.py +++ b/tests/test_webdriver_firefox.py @@ -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