Skip to content

Commit f0ea1c3

Browse files
authored
Merge pull request #585 from mozilla/fix-import-chrome-bookmarks-windows
Fix import chrome bookmarks windows
2 parents c9d026f + 9e3c4f7 commit f0ea1c3

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

modules/page_object_prefs.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, driver: Firefox, **kwargs):
3434
super().__init__(driver, **kwargs)
3535
self.driver = driver
3636

37-
# number of tabs to reach the country tab
37+
# Number of tabs to reach the country tab
3838
TABS_TO_COUNTRY = 6
3939
TABS_TO_SAVE_CC = 5
4040

@@ -49,7 +49,7 @@ def __init__(self):
4949
HTTPS_ONLY_STATUS = HttpsOnlyStatus()
5050

5151
# Function Organization
52-
## Search and Settings
52+
# Search and Settings
5353
def search_engine_dropdown(self) -> Dropdown:
5454
"""Returns the Dropdown region for search engine prefs"""
5555
return Dropdown(
@@ -120,11 +120,11 @@ def select_content_and_action(self, content_type: str, action: str) -> BasePage:
120120

121121
def get_history_menulist(self) -> WebElement:
122122
"""
123-
Gets the webelement for the list of history items that appear in about:preferences
123+
Gets the web element for the list of history items that appear in about:preferences
124124
"""
125125
return self.get_element("history_menulist")
126126

127-
## Payment and Address Management
127+
# Payment and Address Management
128128
def verify_cc_json(
129129
self, cc_info_json: dict, credit_card_fill_obj: CreditCardBase
130130
) -> BasePage:
@@ -384,7 +384,7 @@ def extract_address_data_from_saved_addresses_entry(
384384
telephone=util.normalize_regional_phone_numbers(fields.get("tel"), region),
385385
)
386386

387-
## UI Navigation and Iframe Handling
387+
# UI Navigation and Iframe Handling
388388
def get_saved_payments_popup_iframe(self) -> WebElement:
389389
"""
390390
Returns the iframe object for the dialog panel in the popup
@@ -457,7 +457,7 @@ def get_password_exceptions_popup_iframe(self) -> WebElement:
457457
iframe = self.get_element("browser-popup")
458458
return iframe
459459

460-
## Data Extraction and Processing
460+
# Data Extraction and Processing
461461
def set_country_autofill_panel(self, country: str) -> BasePage:
462462
"""Sets the country value in the autofill view"""
463463
select_country = Select(self.driver.find_element(By.ID, "country"))
@@ -530,8 +530,8 @@ def get_manage_data_site_element(self, site: str) -> WebElement:
530530
element = self.get_element("manage-cookies-site", labels=[site])
531531
return element
532532

533-
## Utility Functions
534-
def import_bookmarks(self, browser_name: str) -> BasePage:
533+
# Utility Functions
534+
def import_bookmarks(self, browser_name: str, platform) -> BasePage:
535535
"""
536536
Press the import browser data button
537537
"""
@@ -556,6 +556,13 @@ def import_bookmarks(self, browser_name: str) -> BasePage:
556556
tries += 1
557557

558558
self.click_on("migration-import-button")
559+
sleep(1)
560+
561+
# On Windows, Tab to and use the Skip button
562+
if platform.lower().startswith("win"):
563+
for _ in range(3):
564+
self.actions.send_keys(Keys.TAB).perform()
565+
self.actions.send_keys(Keys.RETURN).perform()
559566

560567
# There are two messages that indicate a successful migration
561568
self.wait.until(

tests/bookmarks_and_history/test_import_bookmarks_chrome.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def chrome_bookmarks(driver: Firefox, sys_platform, home_folder, tmp_path):
7777
logging.warning(e)
7878
yield None
7979

80-
# Teardown: We don't actually want to destroy the Chrome setup of local users
80+
# Teardown: We don't want to destroy the Chrome setup of local users
8181
if os.path.exists(bookmarks_target):
8282
os.remove(bookmarks_target)
8383
if fake_install:
@@ -91,12 +91,12 @@ def chrome_bookmarks(driver: Firefox, sys_platform, home_folder, tmp_path):
9191
os.rename(tmp_path / "Bookmarks", bookmarks_target)
9292

9393

94-
def test_chrome_bookmarks_imported(chrome_bookmarks, driver: Firefox):
94+
def test_chrome_bookmarks_imported(chrome_bookmarks, driver: Firefox, sys_platform):
9595
if not chrome_bookmarks:
9696
pytest.skip("Google Chrome not installed or directory could not be created")
9797
about_prefs = AboutPrefs(driver, category="General")
9898
about_prefs.open()
9999
about_prefs.click_on("import-browser-data")
100-
about_prefs.import_bookmarks("Chrome")
100+
about_prefs.import_bookmarks("Chrome", sys_platform)
101101
toolbar = Navigation(driver)
102102
toolbar.confirm_bookmark_exists(TEST_PAGE_TITLE)

0 commit comments

Comments
 (0)