Skip to content

Vs/refactoring2 #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93d8297
vs/Part1-Refactoring
vsangereanMOZ Apr 8, 2025
4b1d2bd
vs/Refactoring 2
vsangereanMOZ Apr 30, 2025
1707ddd
Mark tests unstable
Tracy-Walker Apr 29, 2025
30cabe2
Fix Boookmarks tests
Tracy-Walker Apr 29, 2025
5aa69a9
Fix additional test
Tracy-Walker Apr 29, 2025
40a10a8
inital progress on poc
philimon-reset Apr 14, 2025
fcdd60f
continued efforts with live site POC
philimon-reset Apr 15, 2025
be7f2c8
broken change to ignore doorhanger
philimon-reset Apr 17, 2025
40cbb10
base structure for live testing set for walmart address page
philimon-reset Apr 17, 2025
70c03a4
amazon address field working
philimon-reset Apr 23, 2025
8c5cf0a
proof of concept complete
philimon-reset Apr 23, 2025
c7d461f
fix test create address profile
philimon-reset Apr 23, 2025
2bbd201
unfortunate mistake
philimon-reset Apr 23, 2025
ff0a4e5
live site access changed(only relevant for my local testing)
philimon-reset Apr 24, 2025
d13033a
further work to support DE and FR regions and clean up
philimon-reset Apr 24, 2025
1f5c922
webserver implemented
philimon-reset Apr 29, 2025
5be8bdd
amazon_ad minify
philimon-reset Apr 29, 2025
aa93def
region divide added
philimon-reset Apr 29, 2025
4b9c4be
canada address page for amazon added
philimon-reset Apr 29, 2025
b88e7e1
fix conftest
philimon-reset Apr 29, 2025
39e919d
remove loggin
philimon-reset Apr 29, 2025
fb7cd7b
l10n clean up
philimon-reset Apr 29, 2025
0437959
extra field for credit card base class.
philimon-reset Apr 29, 2025
96b6c45
revert change
philimon-reset Apr 29, 2025
4806fce
remove unnessary files
philimon-reset Apr 29, 2025
0a9d0c5
added amazon canada fix
philimon-reset Apr 30, 2025
cb5f594
Update null automation status to Untriaged
soncuteanca May 2, 2025
046a888
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 5, 2025
60ba145
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 5, 2025
1c40c43
Add files that were reverted.
vsangereanMOZ May 5, 2025
f04c64b
Merge remote-tracking branch 'origin/vs/Refactoring2' into vs/Refacto…
vsangereanMOZ May 5, 2025
3f62b33
Mark 2 tests as unstable.
vsangereanMOZ May 5, 2025
fbb6759
Merge remote-tracking branch 'origin/vs/Refactoring2' into vs/Refacto…
vsangereanMOZ May 5, 2025
139705b
Merge branch 'main' into vs/Refactoring2
vsangereanMOZ May 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/page_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def element_has_text(self, name: str, text: str, labels=[]) -> Page:
self.expect(lambda _: text in self.get_element(name, labels=labels).text)
return self

def element_attribute_contains(
def expect_element_attribute_contains(
self, name: str, attr_name: str, attr_value: Union[str, float, int], labels=[]
) -> Page:
"""Expect helper: wait until element attribute contains certain value"""
Expand Down
2 changes: 1 addition & 1 deletion modules/page_object_autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def verify_form_data(self, sample_data: CreditCardBase | AutofillAddressBase):
autofilled_field = self.get_element("form-field", labels=[field_name])
if autofilled_field.tag_name.lower() != "select":
autofilled_field_value = autofilled_field.get_attribute("value")
# self.element_attribute_contains(
# self.expect_element_attribute_contains(
# "form-field", "value", expected_value, labels=[field_name]
# )
else:
Expand Down
10 changes: 10 additions & 0 deletions modules/page_object_example_page.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from selenium.webdriver.common.by import By

from modules.page_base import BasePage


Expand All @@ -10,3 +12,11 @@ class ExamplePage(BasePage):
TITLE = "Example Domain"
MORE_INFO_URL = "https://www.iana.org/help/example-domains"
MORE_INFO_TITLE = "Example Domains"

@BasePage.context_content
def search_selected_header_via_context_menu(self):
"""Open the page, triple-click the <h1>, right-click it to trigger the context menu."""
self.open()
header = (By.TAG_NAME, "h1")
self.triple_click(header)
self.context_click(header)
4 changes: 2 additions & 2 deletions modules/page_object_prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def set_alternative_language(self, lang_code: str) -> BasePage:
self.get_element("language-option-by-code", labels=[lang_code]).click()
select_language.click()
self.get_element("language-settings-add-button").click()
self.element_attribute_contains(
self.expect_element_attribute_contains(
"language-added-list", "last-selected", f"locale-{lang_code}"
)

Expand All @@ -94,7 +94,7 @@ def select_https_only_setting(self, option_id: HttpsOnlyStatus) -> BasePage:
self.find_in_settings("HTTPS")
self.element_clickable(str(option_id))
self.click_on(str(option_id))
self.element_attribute_contains(str(option_id), "checked", "")
self.expect_element_attribute_contains(str(option_id), "checked", "")
return self

def set_default_zoom_level(self, zoom_percentage: int) -> BasePage:
Expand Down
14 changes: 9 additions & 5 deletions tests/address_bar_and_search/test_adaptive_history_autofill.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
WAIT_TIMEOUT = 10
TEST_URL = "https://www.nationalgeographic.com/science/"
EXPECTED_TITLE = "Science"
EXPECTED_TYPE = "autofill_adaptive"
EXPECTED_TEXT_FRAGMENT = "nationalgeographic.com/science"


@pytest.fixture()
Expand All @@ -28,24 +30,26 @@ def test_add_adaptive_history_autofill(driver: Firefox):
nav = Navigation(driver)
tabs = TabBar(driver)

# Step 1: Visit the test site and verify tab title
nav.search(TEST_URL)
WebDriverWait(driver, WAIT_TIMEOUT).until(
lambda d: tabs.get_tab_title(tabs.get_tab(1)) == EXPECTED_TITLE
)

# Step 2: Open new tab, close the original
tabs.new_tab_by_button()
tabs.wait_for_num_tabs(2)
driver.switch_to.window(driver.window_handles[1])

with driver.context(driver.CONTEXT_CHROME):
tabs.get_elements("tab-x-icon")[0].click()

# Step 3: Type in address bar, click adaptive suggestion
nav.type_in_awesome_bar("nat")
with driver.context(driver.CONTEXT_CHROME):
nav.get_element("firefox-suggest").click()

nav.expect_in_content(EC.url_contains(TEST_URL))

# Step 4: Open new tab and check for autofill suggestion
tabs.new_tab_by_button()
tabs.wait_for_num_tabs(2)
driver.switch_to.window(driver.window_handles[-1])
Expand All @@ -54,9 +58,9 @@ def test_add_adaptive_history_autofill(driver: Firefox):
tabs.set_chrome_context()
autofill_element = nav.get_element("search-result-autofill-adaptive-element")

assert autofill_element.get_attribute("type") == "autofill_adaptive", (
f"Expected type 'autofill_adaptive', got '{autofill_element.get_attribute('type')}'"
assert autofill_element.get_attribute("type") == EXPECTED_TYPE, (
f"Expected type '{EXPECTED_TYPE}', got '{autofill_element.get_attribute('type')}'"
)
assert "nationalgeographic.com/science" in autofill_element.text, (
assert EXPECTED_TEXT_FRAGMENT in autofill_element.text, (
f"Autofill text did not contain expected URL. Got: {autofill_element.text}"
)
8 changes: 5 additions & 3 deletions tests/address_bar_and_search/test_add_engine_address_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from modules.browser_object import ContextMenu, Navigation, TabBar

TEST_URL = "https://youtube.com"
EXPECTED_ENGINE = "YouTube"

@pytest.fixture()
def test_case():
Expand All @@ -22,17 +24,17 @@ def test_add_search_engine_from_address_bar(driver: Firefox):
menu = ContextMenu(driver)
tabs = TabBar(driver)

driver.get("https://youtube.com")
driver.get(TEST_URL)
nav.custom_wait(timeout=20).until(lambda d: "youtube.com" in d.current_url)

with driver.context(driver.CONTEXT_CHROME):
nav.context_click_in_awesome_bar()
menu.click_context_item("context-menu-add-search-engine")

tabs.new_tab_by_button()
youtube_tab = tabs.get_tab_by_title("YouTube")
youtube_tab = tabs.get_tab_by_title(EXPECTED_ENGINE)
tabs.close_tab(youtube_tab)

nav.click_on("searchmode-switcher")
nav.element_exists("search-mode-switcher-option", labels=["YouTube"])
nav.element_exists("search-mode-switcher-option", labels=[EXPECTED_ENGINE])
nav.click_on("searchmode-switcher")
38 changes: 16 additions & 22 deletions tests/address_bar_and_search/test_addon_suggestion.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import pytest
from selenium.common.exceptions import TimeoutException
from selenium.webdriver import Firefox
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from modules.browser_object import Navigation

WAIT_TIMEOUT = 10
ADDONS_BASE_URL = "https://addons.mozilla.org/en-US/firefox/addon/"

INPUT_TO_ADDON_NAME = {
"clips": "video-downloadhelper",
"grammar": "languagetool",
"Temp mail": "private-relay",
"pics search": "search_by_image",
"darker theme": "darkreader",
"privacy": "privacy-badger17",
"read aloud": "read-aloud",
}


@pytest.fixture()
def test_case():
Expand All @@ -26,31 +35,16 @@ def test_addon_suggestion_based_on_search_input(driver: Firefox):
"""
C2234714 - Verify that the address bar suggests relevant add-ons based on search input.
"""
input_to_addon_name = {
"clips": "video-downloadhelper",
"grammar": "languagetool",
"Temp mail": "private-relay",
"pics search": "search_by_image",
"darker theme": "darkreader",
"privacy": "privacy-badger17",
"read aloud": "read-aloud",
}

nav = Navigation(driver)
nav.set_awesome_bar()

for input_text, addon_name in input_to_addon_name.items():
for input_text, addon_slug in INPUT_TO_ADDON_NAME.items():
nav.type_in_awesome_bar(input_text)
try:
nav.element_visible("addon-suggestion")
except TimeoutException:
raise AssertionError(
f"Addon suggestion not visible for input: '{input_text}'"
)

nav.select_element_in_nav("addon-suggestion")
if not nav.element_visible("addon-suggestion"):
raise AssertionError(f"Addon suggestion not visible for input: '{input_text}'")

expected_url = f"{ADDONS_BASE_URL}{addon_name}/"
nav.select_element_in_nav("addon-suggestion")
expected_url = f"{ADDONS_BASE_URL}{addon_slug}/"
nav.expect_in_content(EC.url_contains(expected_url))

nav.clear_awesome_bar()
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def test_default_search_provider_change_awesome_bar(driver: Firefox):

driver.get("about:newtab")
nav.open_searchmode_switcher_settings()

prefs.search_engine_dropdown().select_option(SEARCH_ENGINE)

driver.get("about:newtab")
nav.element_attribute_contains("awesome-bar", "placeholder", EXPECTED_PLACEHOLDER)
nav.expect_element_attribute_contains("awesome-bar", "placeholder", EXPECTED_PLACEHOLDER)
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,38 @@ def test_default_search_provider_change_legacy_search_bar(driver: Firefox):
"""
C1365245 - Verify that changing the default search provider is reflected in the legacy search bar.
"""
nav = Navigation(driver)
panel_ui = PanelUi(driver)
customize = CustomizeFirefox(driver)
nav = Navigation(driver)
tabs = TabBar(driver)
prefs = AboutPrefs(driver, category="search")

# Add legacy search bar to toolbar
panel_ui.open_panel_menu()
panel_ui.navigate_to_customize_toolbar()
customize.add_widget_to_toolbar("search-bar")

# Open a new tab and trigger search settings navigation
tabs.new_tab_by_button()
nav.type_in_search_bar(SEARCH_TERM)
nav.click_on_change_search_settings_button()
driver.switch_to.window(driver.window_handles[2])
assert driver.current_url == SEARCH_SETTINGS_URL

# Validate navigation returns to site and settings page opens in new tab
driver.get("https://9gag.com/")
nav.type_in_search_bar(SEARCH_TERM)
nav.click_on_change_search_settings_button()
assert driver.current_url == "https://9gag.com/"
driver.switch_to.window(driver.window_handles[3])
assert driver.current_url == SEARCH_SETTINGS_URL

# Change the default search engine
prefs.open()
prefs.search_engine_dropdown().select_option(SEARCH_ENGINE)
nav.type_in_search_bar(SEARCH_TERM)

# Perform another search and validate engine label
nav.type_in_search_bar(SEARCH_TERM)
with driver.context(driver.CONTEXT_CHROME):
engine_name = driver.find_element(By.CSS_SELECTOR, ".searchbar-engine-name")
assert engine_name.get_attribute("value") == EXPECTED_ENGINE_DISPLAY
Loading