Skip to content

Commit bdc5e6e

Browse files
committed
merge main
2 parents 0d08482 + 17606f8 commit bdc5e6e

34 files changed

+632
-236
lines changed

.github/workflows/smoke.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,32 @@ jobs:
2121
pip3 install 'pipenv==2023.11.15';
2222
pip3 install 'ruff>=0.4.8,<0.5';
2323
bash collect_executables.sh;
24-
sleep 3;
24+
ls .;
2525
rm ./pyproject.toml;
2626
mv ./ci_pyproject.toml ./pyproject.toml;
2727
pipenv install;
28+
- name: Run Setup.exe
29+
id: setup
30+
run: |
31+
.\setup.exe /silent;
32+
Start-Sleep -Seconds 10;
2833
- name: Run Smoke Tests in Win
34+
if: steps.setup.conclusion == 'success'
2935
run: |
30-
pipenv run pytest --fx-executable ./firefox/firefox -n 4 .
36+
pipenv run pytest -n 4 .
3137
$env:TEST_EXIT_CODE = $LASTEXITCODE
3238
mv artifacts artifacts-win || true
3339
exit $env:TEST_EXIT_CODE
40+
- name: Run Smoke Tests in Win (Headed)
41+
if: steps.setup.conclusion == 'success'
42+
run: |
43+
rm ./pyproject.toml;
44+
mv ./ci_pyproject_headed.toml ./pyproject.toml;
45+
pipenv run pytest -n 4 .
46+
$env:TEST_EXIT_CODE = $LASTEXITCODE
47+
rm artifacts/assets -r -Force
48+
mv artifacts/* artifacts-win
49+
exit $env:TEST_EXIT_CODE
3450
- name: Upload artifacts
3551
if: always()
3652
uses: actions/upload-artifact@v4
@@ -58,9 +74,15 @@ jobs:
5874
pipenv install;
5975
- name: Run Smoke Tests in MacOS
6076
run: |
61-
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 . || TEST_EXIT_CODE=$?
77+
pipenv run pytest --fx-executable $(cat ./fx_location) -s -n 4 . || TEST_EXIT_CODE=$?
6278
mv artifacts artifacts-mac || true
6379
exit $TEST_EXIT_CODE
80+
- name: Run Smoke Tests in MacOS (Headed)
81+
run: |
82+
mv ./ci_pyproject_headed.toml ./pyproject.toml;
83+
pipenv run pytest --fx-executable $(cat ./fx_location) -s -n 4 . || TEST_EXIT_CODE=$?
84+
mv -r artifacts/* artifacts-mac/ || true
85+
exit $TEST_EXIT_CODE
6486
- name: Upload artifacts
6587
if: always()
6688
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/venv/
2+
test*.txt
3+
fx_location
24
results.txt
35
err_log.txt
46
**/report.html

ci_pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ log_cli = true
44
log_cli_level = "warn"
55
markers = [
66
"audio: test is reliant on audio",
7-
"pynput: test uses pynput package",
7+
"headed: test must run in headed mode (e.g. uses pynput)",
88
"incident: incident smoke tests",
99
"unstable: temporary mark for unstable tests",
1010
"slow: test is clocked at more than 30s on modern machines",
@@ -16,7 +16,7 @@ markers = [
1616
testpaths = [
1717
"tests"
1818
]
19-
addopts = "-vs --ci --reruns 2 --reruns-delay 1 -m 'not incident and not unstable' --html=artifacts/report.html"
19+
addopts = "-vs --ci --run-headless --reruns 2 --reruns-delay 1 -m 'not incident and not unstable and not headed' --html=artifacts/report.html"
2020

2121
[tool.ruff]
2222
target-version = "py310"

ci_pyproject_headed.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[tool.pytest.ini_options]
2+
generate_report_on_test = true
3+
log_cli = true
4+
log_cli_level = "warn"
5+
markers = [
6+
"audio: test is reliant on audio",
7+
"headed: test must run in headed mode (e.g. uses pynput)",
8+
"incident: incident smoke tests",
9+
"unstable: temporary mark for unstable tests",
10+
"slow: test is clocked at more than 30s on modern machines",
11+
"ci: basic tests to run in ci",
12+
"locale_de: tests run in DE locale versions",
13+
"locale_fr: tests run in FR locale versions",
14+
"locale_gb: tests run in GB locale versions"
15+
]
16+
testpaths = [
17+
"tests"
18+
]
19+
addopts = "-vs --ci --reruns 4 --reruns-delay 1 -m 'not incident and not unstable and headed' --html=artifacts/report_headed.html"
20+
21+
[tool.ruff]
22+
target-version = "py310"

collect_executables.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ echo "~~collect executables~~"
77
## Determine OS and arch
88
UNAME_A=$(uname -a)
99
## Save the system arch info
10+
if [ -n "$COLLECT_LANG" ]
11+
then
12+
COLLECT_LANG=en-US
13+
fi
1014
echo "uname -a: ${UNAME_A}"
1115
if [ -n "$WSL_DISTRO_NAME" ] || [[ $UNAME_A == *"MINGW"* ]]
1216
then
@@ -81,7 +85,7 @@ else
8185
CHANNEL=""
8286
fi
8387
fi
84-
FX_LINK_HTML=$(curl -s https://download.mozilla.org/\?product\=firefox${CHANNEL}-latest-ssl\&os\=${FX_SYS_NAME}\&lang\=en-US)
88+
FX_LINK_HTML=$(curl -s https://download.mozilla.org/\?product\=firefox${CHANNEL}-latest-ssl\&os\=${FX_SYS_NAME}\&lang\=${COLLECT_LANG})
8589
FX_LOC=$(echo "$FX_LINK_HTML" | awk -F '"' '{print $2}')
8690

8791
curl -O "$FX_LOC"
@@ -112,4 +116,17 @@ then
112116
ls firefox*.tar.bz2
113117
mv firefox*.tar.bz2 firefox.tar.bz2
114118
tar -xvjf firefox.tar.bz2
119+
echo "./firefox/firefox" > fx_location
120+
else
121+
if [[ $SYSTEM_NAME == "win" ]]
122+
then
123+
mv Firefox*.exe setup.exe
124+
ls .
125+
else
126+
if [[ $SYSTEM_NAME == "macos" ]]
127+
then
128+
hdiutil attach Firefox*.dmg
129+
echo "/Volume/Firefox/Firefox.app/Contents/MacOS/firefox" > fx_location
130+
fi
131+
fi
115132
fi

conftest.py

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,56 @@ def log_content(opt_ci: bool, driver: Firefox, test_name: str) -> None:
3131
artifacts_loc = "artifacts" if opt_ci else ""
3232
current_time = str(datetime.datetime.now())
3333
current_time = re.sub(r"[^\w_. -]", "_", current_time)
34-
fullpath_chrome = os.path.join(
34+
fullpath_content = os.path.join(
3535
artifacts_loc, f"{test_name}_{current_time}_content.txt"
3636
)
37-
fullpath_content = os.path.join(
37+
fullpath_chrome = os.path.join(
3838
artifacts_loc, f"{test_name}_{current_time}_chrome.txt"
3939
)
4040

41-
# Save Chrome context page source
42-
with open(fullpath_chrome, "w", encoding="utf-8") as fh:
43-
with driver.context(driver.CONTEXT_CHROME):
41+
try:
42+
# Save Chrome context page source
43+
with open(fullpath_chrome, "w", encoding="utf-8") as fh:
44+
with driver.context(driver.CONTEXT_CHROME):
45+
output_contents = driver.page_source
46+
fh.write(output_contents)
47+
48+
# Save Content context page source
49+
with open(fullpath_content, "w", encoding="utf-8") as fh:
4450
output_contents = driver.page_source
4551
fh.write(output_contents)
46-
47-
# Save Content context page source
48-
with open(fullpath_content, "w", encoding="utf-8") as fh:
49-
output_contents = driver.page_source
50-
fh.write(output_contents)
52+
except Exception as e:
53+
logging.error(f"Could not log the html content because of {e}")
5154
return
5255

5356

57+
def sanitize_filename(filename):
58+
# Remove invalid characters
59+
sanitized = re.sub(r'[<>:"/\\|?*]', "", filename)
60+
# Limit to 200 characters
61+
return sanitized[:200]
62+
63+
5464
def pytest_exception_interact(node, call, report):
5565
"""
5666
Method that wraps all test execution, on any exception/failure an artifact with the information about the failure is kept.
5767
"""
5868
if report.failed:
5969
try:
6070
test_name = node.name
71+
test_name = sanitize_filename(test_name)
6172
logging.error(f"Handling exception for test: {test_name}")
62-
logging.error(
63-
f"NODE LOGS HERE {node.funcargs}\n THE FAILED TEST: {test_name}"
64-
)
65-
driver = node.funcargs.get("driver")
66-
opt_ci = node.funcargs.get("opt_ci")
67-
if driver:
68-
log_content(opt_ci, driver, test_name)
69-
screenshot_content(driver, opt_ci, test_name)
73+
if hasattr(node, "funcargs"):
74+
logging.error(
75+
f"NODE LOGS HERE {node.funcargs}\n THE FAILED TEST: {test_name}"
76+
)
77+
driver = node.funcargs.get("driver")
78+
opt_ci = node.funcargs.get("opt_ci")
79+
if driver:
80+
log_content(opt_ci, driver, test_name)
81+
screenshot_content(driver, opt_ci, test_name)
82+
else:
83+
logging.error("Error occurred during collection.")
7084
except Exception as e:
7185
logging.warning("Something went wrong with the exception catching.")
7286
raise e
@@ -236,7 +250,7 @@ def driver(
236250
"""
237251
try:
238252
options = Options()
239-
if opt_headless or opt_ci:
253+
if opt_headless:
240254
options.add_argument("--headless")
241255
options.binary_location = fx_executable
242256
for opt, value in set_prefs:

dev_pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ log_cli = true
55
log_cli_level = "info"
66
markers = [
77
"audio: test is reliant on audio",
8-
"pynput: test uses pynput package",
8+
"headed: test must run in headed mode (e.g. uses pynput)",
99
"incident: incident smoke tests",
1010
"unstable: temporary mark for unstable tests",
1111
"slow: test is clocked at more than 30s on modern machines",

modules/browser_object_panel_ui.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,12 @@ def open_history_menu(self) -> BasePage:
150150
with self.driver.context(self.driver.CONTEXT_CHROME):
151151
self.get_element("panel-ui-history").click()
152152
return self
153+
154+
def open_bookmarks_menu(self) -> BasePage:
155+
"""
156+
Opens the Bookmarks menu
157+
"""
158+
self.open_panel_menu()
159+
with self.driver.context(self.driver.CONTEXT_CHROME):
160+
self.get_element("panel-ui-bookmarks").click()
161+
return self

modules/browser_object_pdf_viewer.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

modules/data/about_prefs.components.json

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -153,57 +153,6 @@
153153
"groups": []
154154
},
155155

156-
"language-set-alternatives-button": {
157-
"selectorData": "manageBrowserLanguagesButton",
158-
"strategy": "id",
159-
"groups": []
160-
},
161-
162-
"language-set-alternatives-popup-select-language": {
163-
"selectorData": "availableLocales",
164-
"strategy": "id",
165-
"groups": [
166-
"doNotCache"
167-
]
168-
},
169-
170-
"language-set-alternatives-popup-select-language-search-more": {
171-
"selectorData": "menuitem[label='Search for more languages…']",
172-
"strategy": "css",
173-
"groups": []
174-
},
175-
176-
"language-set-alternatives-popup-select-language-italian": {
177-
"selectorData": "menuitem[label='Italiano']",
178-
"strategy": "css",
179-
"groups": []
180-
},
181-
182-
"languages-shadow-root": {
183-
"selectorData": "dialog[buttons='accept,cancel,help']",
184-
"strategy": "css",
185-
"groups": []
186-
},
187-
188-
"language-accept-button": {
189-
"selectorData": "button[dlgtype='accept']",
190-
"strategy": "css",
191-
"shadowParent": "languages-shadow-root",
192-
"groups": []
193-
},
194-
195-
"language-add-button": {
196-
"selectorData": "add",
197-
"strategy": "id",
198-
"groups": []
199-
},
200-
201-
"language-list-item": {
202-
"selectorData": "locale-it",
203-
"strategy": "id",
204-
"groups": []
205-
},
206-
207156
"html-root": {
208157
"selectorData": "preferences-root",
209158
"strategy": "id",
@@ -410,18 +359,85 @@
410359
"groups": []
411360
},
412361

362+
"language-set-alternative-button": {
363+
"selectorData": "[data-l10n-id='manage-browser-languages-button']",
364+
"strategy": "css",
365+
"groups": []
366+
},
367+
413368
"remove-selected-button": {
414369
"selectorData": "removeSelected",
415370
"strategy": "id",
416371
"groups": []
417372
},
418373

374+
"language-settings-content": {
375+
"selectorData": "[data-l10n-id='browser-languages-window2']",
376+
"strategy": "css",
377+
"groups": []
378+
},
379+
380+
"language-settings-dialog": {
381+
"selectorData": "BrowserLanguagesDialog",
382+
"strategy": "id",
383+
"groups": []
384+
},
385+
419386
"remove-all-button": {
420387
"selectorData": "removeAll",
421388
"strategy": "id",
422389
"groups": []
423390
},
424391

392+
"language-settings-select": {
393+
"selectorData": "[data-l10n-id='browser-languages-select-language']",
394+
"strategy": "css",
395+
"groups": []
396+
},
397+
398+
"language-search-dropdown": {
399+
"selectorData": "label-box",
400+
"strategy": "id",
401+
"groups": []
402+
},
403+
404+
"language-settings-dropdown": {
405+
"selectorData": ".in-menulist[hasbeenopened='true']",
406+
"strategy": "css",
407+
"groups": []
408+
},
409+
410+
"language-settings-search": {
411+
"selectorData": "menuitem[value='search']",
412+
"strategy": "css",
413+
"groups": []
414+
},
415+
416+
"language-option-by-code": {
417+
"selectorData": "menuitem[value='{}']",
418+
"strategy": "css",
419+
"groups": []
420+
},
421+
422+
"language-added-list": {
423+
"selectorData": "selectedLocales",
424+
"strategy": "id",
425+
"groups": []
426+
},
427+
428+
"language-settings-add-button": {
429+
"selectorData": "button[data-l10n-id='languages-customize-add']",
430+
"strategy": "css",
431+
"groups": []
432+
},
433+
434+
"language-settings-ok": {
435+
"selectorData": "button[dlgtype='accept']",
436+
"strategy": "css",
437+
"shadowParent": "language-settings-dialog",
438+
"groups": []
439+
},
440+
425441
"history_menulist": {
426442
"selectorData": "historyMode",
427443
"strategy": "id",

0 commit comments

Comments
 (0)