diff --git a/modules/browser_object_navigation.py b/modules/browser_object_navigation.py index cf5fd1eab..d107f95ce 100644 --- a/modules/browser_object_navigation.py +++ b/modules/browser_object_navigation.py @@ -886,3 +886,24 @@ def verify_engine_returned(self, engine: str) -> None: self.wait.until( EC.visibility_of_element_located((By.CSS_SELECTOR, engine_locator)) ) + + @BasePage.context_chrome + def verify_https_hidden_in_address_bar(self) -> None: + """ + Wait until the HTTPS prefix is hidden in the address bar display. + """ + self.wait.until( + lambda d: "https" not in self.get_element("awesome-bar").get_attribute("value") + ) + + @BasePage.context_chrome + def verify_address_bar_value_prefix(self, prefix: str) -> None: + """ + Wait until the value in the address bar starts with the given prefix. + + Args: + prefix (str): Expected starting string (e.g., "https://"). + """ + self.wait.until( + lambda d: self.get_element("awesome-bar").get_attribute("value").startswith(prefix) + ) \ No newline at end of file diff --git a/modules/page_base.py b/modules/page_base.py index 0ebc3a0aa..03484e802 100644 --- a/modules/page_base.py +++ b/modules/page_base.py @@ -176,8 +176,9 @@ def perform_key_combo(self, *keys) -> Page: Use ActionChains to perform key combos. Modifier keys should come first in the function call. Usage example: perform_key_combo(Keys.CONTROL, Keys.ALT, "c") presses CTRL+ALT+c. """ - while Keys.CONTROL in keys and self.sys_platform == "Darwin": - keys[keys.index(Keys.CONTROL)] = Keys.COMMAND + if self.sys_platform() == "Darwin": + keys = tuple(Keys.COMMAND if k == Keys.CONTROL else k for k in keys) + for k in keys[:-1]: self.actions.key_down(k) diff --git a/tests/address_bar_and_search/test_copied_url_contains_https.py b/tests/address_bar_and_search/test_copied_url_contains_https.py new file mode 100644 index 000000000..dd7363123 --- /dev/null +++ b/tests/address_bar_and_search/test_copied_url_contains_https.py @@ -0,0 +1,39 @@ +import pytest +from selenium.webdriver import Firefox, Keys + +from modules.browser_object import Navigation + +TEST_WEBSITE = "https://www.firefox.com/" +TEXT = "https" + + +@pytest.fixture() +def test_case(): + return "3028712" + + +def test_copied_url_contains_https(driver: Firefox): + """ + C3028712 - URLs copied from address bar contain https tags + """ + + # Instantiate object + nav = Navigation(driver) + + # Input a URL in the address bar and hit enter + nav.search(TEST_WEBSITE) + + # Check that HTTPS is NOT displayed in the address bar for the website + nav.verify_https_hidden_in_address_bar() + + # Click on the URL bar once and hit CTRL/CMD+c to copy the link + nav.click_in_awesome_bar() + nav.perform_key_combo_chrome(Keys.CONTROL, "c") + + # Open a new tab and paste (CTRL/CMD+v) the link + nav.open_and_switch_to_new_window("tab") + nav.click_in_awesome_bar() + nav.perform_key_combo_chrome(Keys.CONTROL, "v") + + # Check that full link, including https://, is pasted in the address bar + nav.verify_address_bar_value_prefix("https://")