@@ -13,13 +13,13 @@ def test_case():
13
13
return "1901393"
14
14
15
15
16
- CHECK_SITE = "http://cnn "
16
+ CHECK_SITE = "http://example "
17
17
SHORT_SITE = CHECK_SITE .split ("/" )[- 1 ]
18
18
19
19
ERROR_TITLES = ["Hmm. We’re having trouble finding that site." ]
20
20
21
21
22
- def test_server_not_found_error (driver : Firefox ):
22
+ def test_server_not_found_error (driver : Firefox , version : str ):
23
23
"""
24
24
C1901393: - This tests that when a user navigates to a non-existent site, a "Server Not Found" error is
25
25
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):
30
30
tabs = TabBar (driver )
31
31
error_page = ErrorPage (driver )
32
32
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
+
33
36
nav .search (CHECK_SITE )
34
37
35
38
# Verify the tab title
@@ -38,35 +41,37 @@ def test_server_not_found_error(driver: Firefox):
38
41
)
39
42
40
43
# 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
47
45
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 ()
52
48
)
53
49
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
+
55
62
expected_texts = [
56
63
"Try again later" ,
57
64
"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 ,
59
66
]
60
67
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 ]
65
70
66
71
WebDriverWait (driver , 30 ).until (
67
72
lambda d : error_page .get_try_again_button ().is_displayed ()
68
73
)
69
74
70
75
# Verify that the suggested link redirects to the correct page
71
76
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