Skip to content

Commit 2479ebb

Browse files
authored
Merge pull request #130 from mozilla/sl/private-browsing-password-doorhanger
Private Browsing Login Doorhanger
2 parents bca2479 + 8ec8733 commit 2479ebb

File tree

5 files changed

+98
-5
lines changed

5 files changed

+98
-5
lines changed
Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
{
2-
"login-input-field": {
2+
"input-field": {
33
"selectorData": "input[autocomplete='{name}']",
44
"strategy": "css",
55
"groups": [
66
"doNotCache"
77
]
8+
},
9+
10+
"username-field": {
11+
"selectorData": "input[placeholder='username']",
12+
"strategy": "css",
13+
"groups": [
14+
"doNotCache"
15+
]
16+
},
17+
18+
"submit-form": {
19+
"selectorData": "input[value='Log In']",
20+
"strategy": "css",
21+
"groups": [
22+
"doNotCache"
23+
]
24+
},
25+
26+
"save-login-popup": {
27+
"selectorData": "notification-popup",
28+
"strategy": "id",
29+
"groups": [
30+
"doNotCache"
31+
]
832
}
933
}

modules/page_object.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from modules.page_object_about_telemetry import *
1010
from modules.page_object_addons_mozilla_org import *
1111
from modules.page_object_autofill_credit_card import *
12+
from modules.page_object_autofill_login import *
1213
from modules.page_object_autofill_test_basic import *
1314
from modules.page_object_example_page import *
1415
from modules.page_object_fxa_home import *

modules/page_object_autofill_login.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from selenium.webdriver import Firefox
2+
13
from modules.page_object_autofill import Autofill
24

35

@@ -7,3 +9,34 @@ class LoginAutofill(Autofill):
79
"""
810

911
URL_TEMPLATE = "https://mozilla.github.io/form-fill-examples/password_manager/login_and_pw_change_forms.html"
12+
13+
class LoginForm:
14+
"""
15+
Sub class of the Login Autofill Form where you can interact with the Login Form
16+
"""
17+
18+
def __init__(self, parent: "LoginAutofill") -> None:
19+
self.parent = parent
20+
self.username_field = None
21+
self.password_field = None
22+
self.submit_button = None
23+
24+
def fill_username(self, username: str) -> None:
25+
if self.username_field is None:
26+
username_fields = self.parent.get_elements("username-field")
27+
self.username_field = username_fields[1]
28+
self.username_field.send_keys(username)
29+
30+
def fill_password(self, password: str) -> None:
31+
if self.password_field is None:
32+
password_fields = self.parent.get_elements(
33+
"input-field", labels=["current-password"]
34+
)
35+
self.password_field = password_fields[0]
36+
self.password_field.send_keys(password)
37+
38+
def submit(self) -> None:
39+
if self.submit_button is None:
40+
submit_buttons = self.parent.get_elements("submit-form")
41+
self.submit_button = submit_buttons[0]
42+
self.submit_button.click()

tests/menus/test_copy_paste_actions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ def test_login_form_copy_paste(driver: Firefox):
1818
random_text = util.generate_random_text("sentence")
1919

2020
# get the field and send text
21-
password_field = login_fill.get_element(
22-
"login-input-field", labels=["current-password"]
23-
)
21+
password_field = login_fill.get_element("input-field", labels=["current-password"])
2422
password_field.send_keys(random_text)
2523
logging.info(f"Sent the text {random_text} to the textarea.")
2624

2725
# triple click and copy text
28-
login_fill.triple_click("login-input-field", labels=["current-password"])
26+
login_fill.triple_click("input-field", labels=["current-password"])
2927
login_fill.context_click(password_field)
3028
context_menu.click_and_hide_menu("context-menu-copy")
3129

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import Navigation, PanelUi
5+
from modules.page_object import LoginAutofill
6+
7+
SAMPLE_USER = "bob_c"
8+
SAMPLE_PASS = "123456"
9+
10+
11+
@pytest.fixture()
12+
def add_prefs():
13+
return [("signon.rememberSignons", True)]
14+
15+
16+
def test_no_password_doorhanger_private_browsing(driver: Firefox):
17+
"""
18+
C101670: Ensure no save password doorhanger shows up and settings are correct
19+
"""
20+
# instantiate objects
21+
login_auto_fill = LoginAutofill(driver)
22+
panel_ui = PanelUi(driver).open()
23+
nav = Navigation(driver)
24+
panel_ui.open_private_window()
25+
nav.switch_to_new_window()
26+
27+
# open the form, fill the user and password
28+
login_auto_fill.open()
29+
login_form = LoginAutofill.LoginForm(login_auto_fill)
30+
login_form.fill_username(SAMPLE_USER)
31+
login_form.fill_password(SAMPLE_PASS)
32+
login_form.submit()
33+
34+
# ensure that the panel is not open
35+
with driver.context(driver.CONTEXT_CHROME):
36+
save_pass_panel = login_auto_fill.get_element("save-login-popup")
37+
assert save_pass_panel.get_attribute("panelopen") is None

0 commit comments

Comments
 (0)