Skip to content

Commit f06eed8

Browse files
authored
Merge pull request #117 from mozilla/sl/firefox-home-on-launch-1
Firefox Home on Launch
2 parents 428a09d + b70f009 commit f06eed8

File tree

7 files changed

+70
-3
lines changed

7 files changed

+70
-3
lines changed

modules/browser_object_tabbar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ def new_tab_by_keys(self, sys_platform: str) -> BasePage:
5353
).perform()
5454
return self
5555

56+
def new_window_by_keys(self, sys_platform: str) -> BasePage:
57+
"""Use keyboard shortcut to open a new tab"""
58+
if sys_platform == "Darwin":
59+
self.actions.key_down(Keys.COMMAND).send_keys("n").key_up(
60+
Keys.COMMAND
61+
).perform()
62+
else:
63+
self.actions.key_down(Keys.CONTROL).send_keys("n").key_up(
64+
Keys.CONTROL
65+
).perform()
66+
return self
67+
5668
def click_tab_by_title(self, title: str) -> BasePage:
5769
"""Given a full page title, click the corresponding tab"""
5870
with self.driver.context(self.driver.CONTEXT_CHROME):

modules/data/about_prefs.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@
216216
"groups": []
217217
},
218218

219+
"home-new-window-dropdown": {
220+
"selectorData": "homeMode",
221+
"strategy": "id",
222+
"groups": []
223+
},
224+
219225
"home-new-tabs-dropdown-option-default": {
220226
"selectorData": "menuitem[data-l10n-id=\"home-mode-choice-default-fx\"]",
221227
"strategy": "css",

modules/data/panel_ui.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@
9191
]
9292
},
9393

94+
"panel-ui-new-window": {
95+
"selectorData": "appMenu-new-window-button2",
96+
"strategy": "id",
97+
"groups": []
98+
},
99+
94100
"panel-ui-history": {
95101
"selectorData": "appMenu-history-button",
96102
"strategy": "id",

modules/page_object_about_prefs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def __init__(self, page, **kwargs):
4646
def loaded(self):
4747
return self.root if EC.element_to_be_clickable(self.root) else False
4848

49-
def select_option(self, option_name: str, double_click=False):
49+
def select_option(
50+
self, option_name: str, double_click=False, wait_for_selection=True
51+
):
5052
"""Select an option in the dropdown. Does not return self."""
5153
if not self.dropmarker.get_attribute("open") == "true":
5254
self.root.click()
@@ -64,6 +66,7 @@ def select_option(self, option_name: str, double_click=False):
6466
)
6567
else:
6668
matching_menuitems[0].click()
69+
if wait_for_selection:
6770
self.wait.until(EC.element_to_be_selected(matching_menuitems[0]))
6871
return self
6972
else:

tests/address_bar_and_search/test_google_search_counts_us.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from time import sleep
22

3-
import pytest
43
from selenium.webdriver import Firefox
54

65
from modules.browser_object import Navigation

tests/language_packs/test_language_pack_install_addons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_language_pack_install_from_addons(
5757
about_prefs = AboutPrefs(driver, category="general").open()
5858
language_dropdown = about_prefs.get_element("language-dropdown")
5959
dropdown = about_prefs.Dropdown(page=about_prefs, root=language_dropdown)
60-
dropdown.select_option(drop_down_name, double_click=True)
60+
dropdown.select_option(drop_down_name, double_click=True, wait_for_selection=False)
6161

6262
about_prefs.custom_wait(timeout=15).until(
6363
lambda _: about_prefs.get_element("html-root").get_attribute("lang")
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import PanelUi, TabBar
5+
from modules.page_object import AboutNewtab, AboutPrefs
6+
7+
8+
@pytest.fixture()
9+
def set_prefs():
10+
"""Set prefs"""
11+
return [
12+
("browser.startup.homepage", "about:home"),
13+
("browser.startup.blankWindow", "false"),
14+
]
15+
16+
17+
def test_firefox_home_on_launch(driver: Firefox, sys_platform: str):
18+
"""
19+
C143543: setting the default new window to be Firefox Home
20+
"""
21+
# instantiate objs
22+
tabs = TabBar(driver)
23+
new_tab = AboutNewtab(driver)
24+
about_prefs = AboutPrefs(driver, category="home").open()
25+
panel_ui = PanelUi(driver)
26+
27+
# click the dropdown
28+
drop_down = about_prefs.get_element("home-new-window-dropdown")
29+
dropdown = about_prefs.Dropdown(page=about_prefs, root=drop_down)
30+
dropdown.select_option("Firefox Home (Default)", double_click=True)
31+
32+
# make sure that the option was selected correctly
33+
assert drop_down.get_attribute("label") == "Firefox Home (Default)"
34+
panel_ui.open_panel_menu()
35+
panel_ui.select_panel_setting("panel-ui-new-window")
36+
# wait for the number of tabs and switch
37+
tabs.wait_for_num_tabs(2)
38+
driver.switch_to.window(driver.window_handles[-1])
39+
40+
# make sure we are on the correct new tab page
41+
assert new_tab.get_element("body-logo") is not None

0 commit comments

Comments
 (0)