Skip to content

Commit a480790

Browse files
Merge pull request #148 from mozilla/vs/never-remember-history-test
Vs/never remember history test
2 parents 6bf5976 + f6c513f commit a480790

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

modules/data/about_prefs.components.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,5 +393,11 @@
393393
"selectorData": "description[data-l10n-id='history-dontremember-description']",
394394
"strategy": "css",
395395
"groups": []
396+
},
397+
398+
"history_menulist": {
399+
"selectorData": "historyMode",
400+
"strategy": "id",
401+
"groups": []
396402
}
397403
}

modules/page_object_about_prefs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,9 @@ def get_iframe(self) -> WebElement:
322322
Gets the webelement for the iframe that commonly appears in about:preferences
323323
"""
324324
return self.get_element("browser-popup")
325+
326+
def get_history_menulist(self) -> WebElement:
327+
"""
328+
Gets the webelement for the list of history items that appear in about:preferences
329+
"""
330+
return self.get_element("history_menulist")
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import os
2+
import time
3+
4+
import pytest
5+
from selenium.webdriver import Firefox
6+
from selenium.webdriver.common.by import By
7+
8+
from modules.page_object import AboutPrefs
9+
10+
11+
# make sure Firefox remembers history
12+
@pytest.fixture()
13+
def add_prefs():
14+
return [("browser.privatebrowsing.autostart", False)]
15+
16+
17+
def test_never_remember_history(driver: Firefox, sys_platform: str):
18+
"""
19+
C143604: Make sure to set the pref via about:preferences, then check in about:config that the pref has been changed
20+
"""
21+
22+
about_prefs = AboutPrefs(driver, category="privacy").open()
23+
24+
# Change the settings to not remember the browser history
25+
history_menulist = about_prefs.get_history_menulist()
26+
menulist_popup = history_menulist.find_element(By.TAG_NAME, "menupopup")
27+
options = menulist_popup.find_elements(By.TAG_NAME, "menuitem")
28+
29+
# Scrolling for visibility
30+
driver.execute_script("arguments[0].scrollIntoView();", history_menulist)
31+
time.sleep(1)
32+
current_selection = history_menulist.get_attribute("value")
33+
34+
if current_selection != "dontremember":
35+
for option in options:
36+
if option.get_attribute("value") == "dontremember":
37+
option.click()
38+
break
39+
40+
# Verify that the pref is set to True
41+
profile_path = driver.capabilities["moz:profile"]
42+
prefs_file_path = os.path.join(profile_path, "prefs.js")
43+
44+
# Read the contents of the 'prefs.js' file to check for the preference
45+
with open(prefs_file_path, "r") as prefs_file:
46+
prefs_content = prefs_file.read()
47+
48+
# Check that the preference is now True
49+
preference_string = 'user_pref("browser.privatebrowsing.autostart", true);'
50+
assert (
51+
preference_string in prefs_content
52+
), f"The preference {preference_string} is not set correctly."

0 commit comments

Comments
 (0)