Skip to content

Commit ee43be1

Browse files
committed
vs/ Test that pref for history is changed
1 parent 09ec00a commit ee43be1

File tree

1 file changed

+51
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)