Skip to content

Commit a7f3b49

Browse files
sv-hyacoubHani Yacoub
authored andcommitted
Hani/Test URLs copied from address bar contain https tags (#851)
* Test URLs copied from address bar contain https tags * URLs copied from address bar contain https tags * Edit test * Edit test name * edit test * changes * Edit perform_key_combo * Edit comments * edit code * Replace a function * Edit comment --------- Co-authored-by: Hani Yacoub <[email protected]>
1 parent 431d296 commit a7f3b49

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

modules/browser_object_navigation.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,3 +886,24 @@ def verify_engine_returned(self, engine: str) -> None:
886886
self.wait.until(
887887
EC.visibility_of_element_located((By.CSS_SELECTOR, engine_locator))
888888
)
889+
890+
@BasePage.context_chrome
891+
def verify_https_hidden_in_address_bar(self) -> None:
892+
"""
893+
Wait until the HTTPS prefix is hidden in the address bar display.
894+
"""
895+
self.wait.until(
896+
lambda d: "https" not in self.get_element("awesome-bar").get_attribute("value")
897+
)
898+
899+
@BasePage.context_chrome
900+
def verify_address_bar_value_prefix(self, prefix: str) -> None:
901+
"""
902+
Wait until the value in the address bar starts with the given prefix.
903+
904+
Args:
905+
prefix (str): Expected starting string (e.g., "https://").
906+
"""
907+
self.wait.until(
908+
lambda d: self.get_element("awesome-bar").get_attribute("value").startswith(prefix)
909+
)

modules/page_base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ def perform_key_combo(self, *keys) -> Page:
176176
Use ActionChains to perform key combos. Modifier keys should come first in the function call.
177177
Usage example: perform_key_combo(Keys.CONTROL, Keys.ALT, "c") presses CTRL+ALT+c.
178178
"""
179-
while Keys.CONTROL in keys and self.sys_platform == "Darwin":
180-
keys[keys.index(Keys.CONTROL)] = Keys.COMMAND
179+
if self.sys_platform() == "Darwin":
180+
keys = tuple(Keys.COMMAND if k == Keys.CONTROL else k for k in keys)
181+
181182
for k in keys[:-1]:
182183
self.actions.key_down(k)
183184

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pytest
2+
from selenium.webdriver import Firefox, Keys
3+
4+
from modules.browser_object import Navigation
5+
6+
TEST_WEBSITE = "https://www.firefox.com/"
7+
TEXT = "https"
8+
9+
10+
@pytest.fixture()
11+
def test_case():
12+
return "3028712"
13+
14+
15+
def test_copied_url_contains_https(driver: Firefox):
16+
"""
17+
C3028712 - URLs copied from address bar contain https tags
18+
"""
19+
20+
# Instantiate object
21+
nav = Navigation(driver)
22+
23+
# Input a URL in the address bar and hit enter
24+
nav.search(TEST_WEBSITE)
25+
26+
# Check that HTTPS is NOT displayed in the address bar for the website
27+
nav.verify_https_hidden_in_address_bar()
28+
29+
# Click on the URL bar once and hit CTRL/CMD+c to copy the link
30+
nav.click_in_awesome_bar()
31+
nav.perform_key_combo_chrome(Keys.CONTROL, "c")
32+
33+
# Open a new tab and paste (CTRL/CMD+v) the link
34+
nav.open_and_switch_to_new_window("tab")
35+
nav.click_in_awesome_bar()
36+
nav.perform_key_combo_chrome(Keys.CONTROL, "v")
37+
38+
# Check that full link, including https://, is pasted in the address bar
39+
nav.verify_address_bar_value_prefix("https://")

0 commit comments

Comments
 (0)