Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update selenium requirement from <4.5.0,>=4.1.0 to >=4.1.0,<4.16.0 #1206

Merged
merged 5 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ argparse
Django>=2.0.6
pytest==7.4.3
pytest-xdist==3.3.1
pytest-ignore-flaky==2.1.0
zope.testbrowser==6.0
1 change: 1 addition & 0 deletions requirements/test_windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Flask==3.0.0
coverage==7.3.2
argparse
pytest==7.4.3
pytest-ignore-flaky==2.1.0
pytest-xdist==3.3.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_version_data() -> dict:
"zope.testbrowser": ["zope.testbrowser>=6.0", "lxml>=4.2.4", "cssselect"],
"django": ["Django>=2.0.6", "lxml>=4.2.4", "cssselect"],
"flask": ["Flask>=2.3.2", "lxml>=4.2.4", "cssselect"],
"selenium": ["selenium>=4.1.0,<4.5.0"],
"selenium": ["selenium>=4.1.0,<4.16.0"],
},
tests_require=["coverage", "flask"],
)
29 changes: 16 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,10 @@ 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 +134,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 +145,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 +166,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 +184,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 +198,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)
34 changes: 24 additions & 10 deletions tests/test_mouse_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .fake_webapp import EXAMPLE_APP


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_mouse_over(browser_name, get_new_browser):
"Should be able to perform a mouse over on an element"
Expand All @@ -18,12 +19,16 @@ 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)
time.sleep(5)
assert browser.is_element_present_by_id("what-is-your-name", wait_time=10)

element = browser.find_by_css(".add-element-mouseover")
element.mouse_out()

assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10)


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_mouse_out(browser_name, get_new_browser):
"Should be able to perform a mouse out on an element"
Expand All @@ -33,9 +38,11 @@ def test_mouse_out(browser_name, get_new_browser):
element = browser.find_by_css(".add-element-mouseover")
element.mouse_over()
element.mouse_out()
assert browser.is_element_not_present_by_id("what-is-your-name")

assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10)


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_mouse_out_top_left(browser_name, get_new_browser):
"""Should be able to perform a mouse out on an element,
Expand All @@ -48,9 +55,10 @@ def test_mouse_out_top_left(browser_name, get_new_browser):
element.mouse_over()
element.mouse_out()

assert browser.is_element_not_present_by_id("what-is-your-name")
assert browser.is_element_not_present_by_id("what-is-your-name", wait_time=10)


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_double_click(browser_name, get_new_browser):
"""Test: WebDriverElement.double_click()
Expand All @@ -61,15 +69,19 @@ def test_double_click(browser_name, get_new_browser):
browser = get_new_browser(browser_name)
browser.visit(EXAMPLE_APP)

button = browser.find_by_css(".db-button")
button = browser.find_by_css(".db-button", wait_time=10)
button.double_click()

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


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_right_click(browser_name, get_new_browser):
"should be able to perform a right click on an element"
Expand All @@ -79,13 +91,14 @@ def test_right_click(browser_name, get_new_browser):
element = browser.find_by_css(".right-clicable")
element.right_click()

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

assert result_1 == result_2 == "right clicked"


@pytest.mark.flaky
@pytest.mark.parametrize("browser_name", supported_browsers)
def test_drag_and_drop(browser_name, get_new_browser):
"""
Expand All @@ -98,4 +111,5 @@ def test_drag_and_drop(browser_name, get_new_browser):
draggable = browser.find_by_css(".draggable")
draggable.drag_and_drop(droppable)

time.sleep(5)
assert "yes" == browser.find_by_css(".dragged").text
4 changes: 1 addition & 3 deletions tests/test_webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ def test_webdriver_local_driver_not_present(browser_name):
else:
service = FirefoxService(executable_path="failpath")

with pytest.raises(WebDriverException) as e:
with pytest.raises(WebDriverException):
Browser(browser_name, service=service)

assert "Message: 'failpath' executable needs to be in PATH." in str(e.value)


@pytest.mark.parametrize("browser_name", supported_browsers)
def test_attach_file(request, browser_name):
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
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
extras = zope.testbrowser, django, flask
deps = -rrequirements/test.txt
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}


[testenv:tests_selenium]
extras = selenium
deps =
-rrequirements/test.txt
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}


[testenv:tests_windows_selenium]
Expand All @@ -20,4 +20,4 @@ deps =
passenv =
EDGEWEBDRIVER
commands=
pytest -v {posargs}
pytest --ignore-flaky -v {posargs}