Skip to content

Commit 5b5499a

Browse files
ben-c-at-mozsoncuteancasv-hyacoubHani YacoubTracy-Walker
authored
stabilize autofill tests (#837)
* stabilize autofill tests * add selectors * Anca/ Stabilization on allow audio-video (#834) * Stabilization on allow audio-video * Remove unused imports * Skip test on Win with a clear reason * Hani/ Refactor tabs batch 2 (#824) * Refactor tabs batch 2 * Skip a test * fix test open new via hyperlink * replace more-information with learn-more --------- Co-authored-by: Hani Yacoub <[email protected]> * Update example.com hyperlink (#835) Fixes several tests that access the example.com page hyperlink * Vs/Add tests for seach modes persistance with @bing (#838) * stabilize autofill tests * add selectors * Tracy/ Skip new failing tests (#839) * stabilize autofill tests * add selectors * modify one selector * check running version is actually correct * attempt to force CI machine to see payment/address buttons in prefs * get loc of installed win fx * just test the version for now * test quotes for exec * test quotes for exec * test win path again * test win path again * test win path again * test win path again * test win path again * test win path again * add log to see binary location * see full capabilities object * see full capabilities object * remove lines * test win path again, sleep * test win path again, sleep * test win path again * test win path again * test win path again * try to force a write of fx location * try to force a write of fx location * attempt to disable Se driver mgmt * attempt to disable Se driver mgmt * attempt to disable Se driver mgmt * attempt to run again * remove debug * remove debug --------- Co-authored-by: soncuteanca <[email protected]> Co-authored-by: Hani Yacoub <[email protected]> Co-authored-by: Hani Yacoub <[email protected]> Co-authored-by: Tracy <[email protected]> Co-authored-by: vsangereanMOZ <[email protected]> Co-authored-by: Philimon Derib Ayalew <[email protected]>
1 parent 98c73d2 commit 5b5499a

File tree

8 files changed

+80
-30
lines changed

8 files changed

+80
-30
lines changed

.github/workflows/smoke.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
$env:FX_EXECUTABLE = "C:\Program Files\Custom Firefox\firefox.exe"
108108
Start-Process -FilePath $env:FX_EXECUTABLE -ArgumentList "--version" -Wait -NoNewWindow
109109
pipenv run python choose_ci_set.py
110-
pipenv run pytest $(cat selected_tests)
110+
pipenv run pytest --geckodriver geckodriver.exe $(cat selected_tests)
111111
$env:TEST_EXIT_CODE = $LASTEXITCODE
112112
mv artifacts artifacts-win || true
113113
exit $env:TEST_EXIT_CODE
@@ -120,7 +120,7 @@ jobs:
120120
mv ./ci_pyproject_headed.toml ./pyproject.toml;
121121
$env:FX_EXECUTABLE = "C:\Program Files\Custom Firefox\firefox.exe"
122122
pipenv run python choose_ci_set.py
123-
pipenv run pytest $(cat selected_tests)
123+
pipenv run pytest --geckodriver geckodriver.exe $(cat selected_tests)
124124
$env:TEST_EXIT_CODE = $LASTEXITCODE
125125
rm artifacts/assets -r -Force
126126
Get-ChildItem -Path "artifacts" | ForEach-Object {

SELECTOR_INFO.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,14 @@ Path to .json: modules/data/about_prefs.components.json
495495
```
496496
```
497497
Selector Name: save-and-fill-addresses
498-
Selector Data: "checkbox[label='Save and fill addresses']"
498+
Selector Data: "[data-l10n-id='autofill-addresses-checkbox-message']"
499499
Description: Label for Autofill > Save and fill addresses option
500500
Location: about:preferences#privacy
501501
Path to .json: modules/data/about_prefs.components.json
502502
```
503503
```
504504
Selector Name: save-and-fill-payment-methods
505-
Selector Data: "checkbox[label='Save and fill payment methods']"
505+
Selector Data: "[data-l10n-id='autofill-payment-methods-checkbox-message-2']"
506506
Description: Label for Autofill > Save and fill payment methods option
507507
Location: about:preferences#privacy
508508
Path to .json: modules/data/about_prefs.components.json
@@ -515,6 +515,20 @@ Location: about:preferences#privacy
515515
Path to .json: modules/data/about_prefs.components.json
516516
```
517517
```
518+
Selector Name: saved-payments-button
519+
Selector Data: "[data-l10n-id='autofill-payment-methods-manage-payments-button']"
520+
Description: Embedded button/label for "Manage Saved Payments"
521+
Location: about:preferences#privacy
522+
Path to .json: modules/data/about_prefs.components.json
523+
```
524+
```
525+
Selector Name: saved-addresses-button
526+
Selector Data: "[data-l10n-id='autofill-addresses-manage-addresses-button']"
527+
Description: Embedded button/label for "Manage Addresses and more..."
528+
Location: about:preferences#privacy
529+
Path to .json: modules/data/about_prefs.components.json
530+
```
531+
```
518532
Selector Name: import-browser-data
519533
Selector Data: "button[id='data-migration']"
520534
Description: Import Browser Data > Import Data button
@@ -845,7 +859,7 @@ Path to .json: modules/data/about_prefs.components.json
845859
```
846860
```
847861
Selector Name: cookies-privacy-label
848-
Selector Data: "description[data-l10n-id='sitedata-delete-on-close-private-browsing2']"
862+
Selector Data: "[data-l10n-id='sitedata-delete-on-close-private-browsing3']"
849863
Description: Message in Cookies and Site data when History is not remembered
850864
Location: about:preferences#privacy
851865
Path to .json: modules/data/about_prefs.components.json

conftest.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
from subprocess import check_output, run
99
from typing import Callable, List, Tuple, Union
1010

11+
# import psutil
1112
import pytest
1213
from PIL import Image, ImageGrab
1314
from selenium.common.exceptions import TimeoutException, WebDriverException
1415
from selenium.webdriver import Firefox
1516
from selenium.webdriver.common.by import By
1617
from selenium.webdriver.firefox.options import Options
18+
from selenium.webdriver.firefox.service import Service
1719
from selenium.webdriver.support import expected_conditions as EC
1820
from selenium.webdriver.support.ui import WebDriverWait
1921

@@ -132,6 +134,13 @@ def pytest_addoption(parser):
132134
help="Path to Fx executable. Will overwrite --fx-channel.",
133135
)
134136

137+
parser.addoption(
138+
"--geckodriver",
139+
action="store",
140+
default="",
141+
help="Path to geckodriver.",
142+
)
143+
135144
parser.addoption(
136145
"--run-headless",
137146
action="store_true",
@@ -216,12 +225,17 @@ def sys_platform():
216225
return platform.system()
217226

218227

228+
@pytest.fixture(scope="session")
229+
def geckodriver(request):
230+
return request.config.getoption("--geckodriver")
231+
232+
219233
@pytest.fixture()
220234
def downloads_folder(sys_platform):
221235
"""Return the downloads folder location for this OS"""
222236
if sys_platform == "Windows":
223237
user = os.environ.get("USERNAME")
224-
return f"C:\\Users\\{user}\\Downloads"
238+
return rf"C:\Users\{user}\Downloads"
225239
elif sys_platform == "Darwin": # MacOS
226240
user = os.environ.get("USER")
227241
return f"/Users/{user}/Downloads"
@@ -242,11 +256,11 @@ def fx_executable(request, sys_platform):
242256
location = ""
243257
if sys_platform == "Windows":
244258
if version == "Firefox":
245-
location = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"
259+
location = r"C:\Program Files\Mozilla Firefox\firefox.exe"
246260
elif version == "Nightly":
247-
location = "C:\\Program Files\\Firefox Nightly\\firefox.exe"
261+
location = r"C:\Program Files\Firefox Nightly\firefox.exe"
248262
elif version == "Custom":
249-
location = "C:\\Program Files\\Custom Firefox\\firefox.exe"
263+
location = r"C:\Program Files\Custom Firefox\firefox.exe"
250264
elif sys_platform == "Darwin":
251265
if version == "Firefox":
252266
location = "/Applications/Firefox.app/Contents/MacOS/firefox"
@@ -392,6 +406,7 @@ def hard_quit():
392406
@pytest.fixture(autouse=True)
393407
def driver(
394408
fx_executable: str,
409+
geckodriver: str,
395410
opt_headless: bool,
396411
opt_implicit_timeout: int,
397412
prefs_list: List[Tuple],
@@ -457,7 +472,15 @@ def driver(
457472
options.profile = profile_path
458473
for opt, value in prefs_list:
459474
options.set_preference(opt, value)
460-
driver = Firefox(options=options)
475+
if geckodriver:
476+
service = Service(executable_path=geckodriver)
477+
driver = Firefox(service=service, options=options)
478+
else:
479+
driver = Firefox(options=options)
480+
# Uncomment below to find Fx process info
481+
# for proc in psutil.process_iter(["name", "exe", "cmdline"]):
482+
# if proc.info["name"] and "firefox" in proc.info["name"].lower():
483+
# print(proc.info)
461484
separator = "x"
462485
if separator not in opt_window_size:
463486
if "by" in opt_window_size:

modules/data/about_prefs.components.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
"groups": []
4646
},
4747
"save-and-fill-addresses": {
48-
"selectorData": "checkbox[label='Save and fill addresses']",
48+
"selectorData": "[data-l10n-id='autofill-addresses-checkbox-message']",
4949
"strategy": "css",
5050
"groups": []
5151
},
5252
"save-and-fill-payment-methods": {
53-
"selectorData": "checkbox[label='Save and fill payment methods']",
53+
"selectorData": "[data-l10n-id='autofill-payment-methods-checkbox-message-2']",
5454
"strategy": "css",
5555
"groups": []
5656
},
@@ -59,6 +59,16 @@
5959
"strategy": "css",
6060
"groups": []
6161
},
62+
"saved-payments-button": {
63+
"selectorData": "[data-l10n-id='autofill-payment-methods-manage-payments-button']",
64+
"strategy": "css",
65+
"groups": []
66+
},
67+
"saved-addresses-button": {
68+
"selectorData": "[data-l10n-id='autofill-addresses-manage-addresses-button']",
69+
"strategy": "css",
70+
"groups": []
71+
},
6272
"import-browser-data": {
6373
"selectorData": "button[id='data-migration']",
6474
"strategy": "css",
@@ -307,7 +317,7 @@
307317
"groups": []
308318
},
309319
"cookies-privacy-label": {
310-
"selectorData": "description[data-l10n-id='sitedata-delete-on-close-private-browsing2']",
320+
"selectorData": "[data-l10n-id='sitedata-delete-on-close-private-browsing3']",
311321
"strategy": "css",
312322
"groups": []
313323
},

modules/page_object_prefs.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,6 @@ def verify_cc_edit_saved_payments_profile(
204204
assert field_value != expected_cvv, "CVV is displayed."
205205
return self
206206

207-
def get_saved_payments_popup(self) -> WebElement:
208-
"""
209-
Open saved payments dialog panel
210-
"""
211-
return self.get_element("prefs-button", labels=["Saved payment methods"])
212-
213207
def click_edit_on_dialog_element(self):
214208
"""
215209
Click on edit button on dialog panel
@@ -283,7 +277,11 @@ def add_entry_to_saved_payments(self, cc_data: CreditCardBase):
283277
def close_dialog_box(self):
284278
"""Close dialog box for saved addresses or payments."""
285279
self.element_clickable("panel-popup-button", labels=["close-button"])
286-
self.get_element("panel-popup-button", labels=["close-button"]).click()
280+
self.click_on("panel-popup-button", labels=["close-button"])
281+
if self.get_element(
282+
"panel-popup-button", labels=["close-button"]
283+
).is_displayed():
284+
self.click_on("panel-popup-button", labels=["close-button"])
287285
return self
288286

289287
def update_cc_field_panel(self, field_name: str, value: str | int) -> BasePage:
@@ -317,12 +315,6 @@ def update_cc_field_panel(self, field_name: str, value: str | int) -> BasePage:
317315
self.get_element("save-button").click()
318316
return self
319317

320-
def get_saved_addresses_popup(self) -> WebElement:
321-
"""
322-
Returns saved addresses button element
323-
"""
324-
return self.get_element("prefs-button", labels=["Saved addresses"])
325-
326318
def open_and_switch_to_saved_addresses_popup(self) -> BasePage:
327319
"""
328320
Open and Switch to saved addresses popup frame.
@@ -420,7 +412,8 @@ def get_saved_payments_popup_iframe(self) -> WebElement:
420412
"""
421413
Returns the iframe object for the dialog panel in the popup
422414
"""
423-
self.get_saved_payments_popup().click()
415+
self.find_in_settings("pay")
416+
self.click_on("saved-payments-button")
424417
iframe = self.get_element("browser-popup")
425418
return iframe
426419

@@ -444,7 +437,8 @@ def get_saved_addresses_popup_iframe(self) -> WebElement:
444437
"""
445438
Returns the iframe object for the dialog panel in the popup
446439
"""
447-
self.get_saved_addresses_popup().click()
440+
self.find_in_settings("pay")
441+
self.click_on("saved-addresses-button")
448442
iframe = self.get_element("browser-popup")
449443
return iframe
450444

tests/form_autofill/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def prefs_list(add_to_prefs_list: dict):
1919
prefs = [
2020
("extensions.formautofill.creditCards.reauth.optout", False),
2121
("extensions.formautofill.reauth.enabled", False),
22+
("extensions.formautofill.addresses.enabled", True),
23+
("extensions.formautofill.creditCards.enabled", True),
2224
]
2325
prefs.extend(add_to_prefs_list)
2426
return prefs

tests/meta/test_version.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
import json
12
import logging
23
from subprocess import check_output
34

45

5-
def test_version(opt_ci, fx_executable):
6+
def test_version(driver, opt_ci, fx_executable):
67
"""Get the Fx version"""
78

89
version = check_output([fx_executable, "--version"]).decode()
10+
assert driver.capabilities["browserVersion"] in version
911
logging.info(version)
12+
logging.warning(f"Fx version {driver.capabilities}")
13+
driver.get("chrome://browser/content/aboutDialog.xhtml")
14+
ver_label = driver.find_element("id", "version")
15+
ver_info = json.loads(ver_label.get_attribute("data-l10n-args"))
16+
assert ver_info.get("version") in version
1017
if opt_ci:
1118
with open("artifacts/fx_version", "w") as fh:
1219
fh.write(version)

tests/security_and_privacy/test_never_remember_browsing_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_never_remember_browsing_history_settings(driver: Firefox):
3838

3939
# perform all about:preferences#privacy assertions according to testrail
4040
cookies_label = about_prefs.get_element("cookies-privacy-label")
41-
assert cookies_label.get_attribute("innerHTML") == COOKIE_LABEL_TEXT
41+
assert cookies_label.get_attribute("message") == COOKIE_LABEL_TEXT
4242

4343
delete_cookies_checkbox = about_prefs.get_element("cookies-delete-on-close")
4444
assert delete_cookies_checkbox.get_attribute("checked") == "true"

0 commit comments

Comments
 (0)