Skip to content

Commit 684b3b1

Browse files
Merge pull request #519 from mozilla/philimon/default_profile_fix
philimon/default_profile_fix
2 parents 4f01e32 + b8622fe commit 684b3b1

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

tests/profile/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.page_object_about_pages import AboutProfiles
25

36

47
@pytest.fixture()
@@ -14,6 +17,12 @@ def prefs_list(add_to_prefs_list: dict):
1417
return prefs
1518

1619

20+
@pytest.fixture()
21+
def about_profiles(driver: Firefox):
22+
ap = AboutProfiles(driver)
23+
yield ap
24+
25+
1726
@pytest.fixture()
1827
def add_to_prefs_list():
1928
return []

tests/profile/test_set_default_profile.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ def create_profiles(profile_paths, sys_platform):
7777
os.remove(profile_file)
7878

7979

80-
def test_set_default_profile(driver: Firefox, opt_ci):
80+
def test_set_default_profile(
81+
driver: Firefox, opt_ci: bool, about_profiles: AboutProfiles
82+
):
8183
"""
82-
C130792: Set the default profile through the firefox browser
84+
C130792: Set the default profile through the firefox
85+
86+
Arguments:
87+
about_profiles: AboutProfiles page object model.
88+
opt_ci: Boolean to verify if test is run in ci.
8389
"""
84-
about_profiles = AboutProfiles(driver)
8590

8691
# Get the profiles container, extract all relevant children under it.
8792
about_profiles.open()
@@ -105,28 +110,29 @@ def test_set_default_profile(driver: Firefox, opt_ci):
105110
logging.info(f"Found the default profile at {i}!")
106111
cur_default = i
107112
break
113+
test_profile_idx = 0 if cur_default != 0 else cur_default + 1
108114

109115
# Set test profile as the default and verify the rows
110116
logging.info("Preparing to set test profile to the default.")
111117
about_profiles.get_element(
112118
"profile-container-item-button",
113-
parent_element=profiles[-1],
119+
parent_element=profiles[test_profile_idx],
114120
labels=["profiles-set-as-default"],
115121
).click()
116122

117123
# Refetch data to ensure no stale elements
118124
profiles = about_profiles.get_all_children("profile-container")
119-
120-
table_rows = about_profiles.get_element(
125+
test_profile_rows = about_profiles.get_element(
121126
"profile-container-item-table-row",
122127
multiple=True,
123-
parent_element=profiles[-1],
128+
parent_element=profiles[test_profile_idx],
129+
)
130+
default_profile_information = about_profiles.get_element(
131+
"profile-container-item-table-row-value", parent_element=test_profile_rows[0]
124132
)
133+
125134
about_profiles.wait.until(
126-
lambda _: about_profiles.get_element(
127-
"profile-container-item-table-row-value", parent_element=table_rows[0]
128-
).get_attribute("innerHTML")
129-
== "yes"
135+
lambda _: default_profile_information.get_attribute("innerHTML") == "yes"
130136
)
131137
logging.info("Verified that test profile was set to the default.")
132138

0 commit comments

Comments
 (0)