Skip to content

Commit 48cf5da

Browse files
authored
Merge pull request #460 from mozilla/as/adjust-server-not-found-error-test
Anca/Fix server not found error
2 parents d5e89c1 + 64f46b0 commit 48cf5da

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

tests/address_bar_and_search/test_server_not_found_error.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def test_case():
1313
return "1901393"
1414

1515

16-
CHECK_SITE = "http://cnn"
16+
CHECK_SITE = "http://example"
1717
SHORT_SITE = CHECK_SITE.split("/")[-1]
1818

1919
ERROR_TITLES = ["Hmm. We’re having trouble finding that site."]
2020

2121

22-
def test_server_not_found_error(driver: Firefox):
22+
def test_server_not_found_error(driver: Firefox, version: str):
2323
"""
2424
C1901393: - This tests that when a user navigates to a non-existent site, a "Server Not Found" error is
2525
displayed. The error page contains the correct elements, and the suggested link redirects to the appropriate page.
@@ -30,6 +30,9 @@ def test_server_not_found_error(driver: Firefox):
3030
tabs = TabBar(driver)
3131
error_page = ErrorPage(driver)
3232

33+
# Auto-detect if this is a Nightly build by checking the version string
34+
is_nightly = any(identifier in version.lower() for identifier in ["a1", "nightly"])
35+
3336
nav.search(CHECK_SITE)
3437

3538
# Verify the tab title
@@ -38,35 +41,37 @@ def test_server_not_found_error(driver: Firefox):
3841
)
3942

4043
# Verify elements on the error page
41-
error_title = error_page.get_error_title()
42-
assert (
43-
error_title in ERROR_TITLES
44-
), f"Expected error title text not found. Actual: {error_title}"
45-
46-
error_short_description = error_page.get_error_short_description()
44+
assert error_page.get_error_title() in ERROR_TITLES
4745
assert (
48-
f"We can’t connect to the server at {SHORT_SITE}" in error_short_description
49-
), (
50-
f"Expected error short description text not found."
51-
f"Actual: {error_short_description}"
46+
f"We can’t connect to the server at {SHORT_SITE}"
47+
in error_page.get_error_short_description()
5248
)
5349

54-
error_long_description_items = error_page.get_error_long_description_items()
50+
# Set the permission text based on what version is actually running
51+
if is_nightly:
52+
permission_message = (
53+
"Check that Nightly has permission to access the web (you might be connected but behind "
54+
"a firewall)"
55+
)
56+
else:
57+
permission_message = (
58+
"Check that Firefox has permission to access the web (you might be connected but behind "
59+
"a firewall)"
60+
)
61+
5562
expected_texts = [
5663
"Try again later",
5764
"Check your network connection",
58-
"Check that Firefox has permission to access the web (you might be connected but behind a firewall)",
65+
permission_message,
5966
]
6067

61-
for i, item in enumerate(error_long_description_items):
62-
assert (
63-
item.text == expected_texts[i]
64-
), f"Expected error long description item text not found. Actual: {item.text}"
68+
for i, item in enumerate(error_page.get_error_long_description_items()):
69+
assert item.text == expected_texts[i]
6570

6671
WebDriverWait(driver, 30).until(
6772
lambda d: error_page.get_try_again_button().is_displayed()
6873
)
6974

7075
# Verify that the suggested link redirects to the correct page
7176
error_page.get_error_suggestion_link().click()
72-
nav.expect_in_content(EC.url_contains("https://www.cnn.com/"))
77+
nav.expect_in_content(EC.url_contains("https://www.example.com/"))

0 commit comments

Comments
 (0)