|
| 1 | +import pytest |
| 2 | +from selenium.webdriver import Firefox |
| 3 | + |
| 4 | +from modules.browser_object import PanelUi, TabBar |
| 5 | +from modules.page_object_about_prefs import AboutPrefs |
| 6 | + |
| 7 | +links = [ |
| 8 | + "about:about", |
| 9 | + "about:addons", |
| 10 | + "about:cache", |
| 11 | + "about:config", |
| 12 | + "about:buildconfig", |
| 13 | + "about:robots", |
| 14 | + "about:blank", |
| 15 | +] |
| 16 | + |
| 17 | +COOKIE_LABEL_TEXT = "Based on your history settings, Firefox deletes cookies and site data from your session when you close the browser." |
| 18 | +HISTORY_LABEL_TEXT = "Firefox will use the same settings as private browsing, and will not remember any history as you browse the Web." |
| 19 | + |
| 20 | + |
| 21 | +@pytest.fixture() |
| 22 | +def add_prefs(): |
| 23 | + return [("browser.privatebrowsing.autostart", True)] |
| 24 | + |
| 25 | + |
| 26 | +def test_never_remember_browsing_history_settings(driver: Firefox): |
| 27 | + """ |
| 28 | + C102381.1: Ensure that setting the browser to never remember history has the correct configurations in about:preferences |
| 29 | + """ |
| 30 | + # instantiate objs |
| 31 | + about_prefs = AboutPrefs(driver, category="privacy").open() |
| 32 | + |
| 33 | + # perform all about:preferences#privacy assertions according to testrail |
| 34 | + cookies_label = about_prefs.get_element("cookies-privacy-label") |
| 35 | + assert cookies_label.get_attribute("innerHTML") == COOKIE_LABEL_TEXT |
| 36 | + |
| 37 | + delete_cookies_checkbox = about_prefs.get_element("cookies-delete-on-close") |
| 38 | + assert delete_cookies_checkbox.get_attribute("checked") == "true" |
| 39 | + |
| 40 | + save_password = about_prefs.get_element("logins-ask-to-save-password") |
| 41 | + assert save_password.get_attribute("checked") is None |
| 42 | + |
| 43 | + login_exceptions = about_prefs.get_element("logins-exceptions") |
| 44 | + assert login_exceptions.get_attribute("disabled") == "true" |
| 45 | + |
| 46 | + history_label = about_prefs.get_element("history-privacy-label") |
| 47 | + assert history_label.get_attribute("innerHTML") == HISTORY_LABEL_TEXT |
| 48 | + |
| 49 | + |
| 50 | +def test_never_remember_browsing_history_from_panel(driver: Firefox): |
| 51 | + """ |
| 52 | + C102381.2: Ensure that setting the browser to never remember history does not actually save any history |
| 53 | + """ |
| 54 | + panel_ui = PanelUi(driver).open() |
| 55 | + tabs = TabBar(driver) |
| 56 | + # util = Utilities() |
| 57 | + |
| 58 | + num_tabs = 6 |
| 59 | + |
| 60 | + # open some tabs |
| 61 | + for i in range(num_tabs): |
| 62 | + driver.get(links[i]) |
| 63 | + tabs.new_tab_by_button() |
| 64 | + tabs.switch_to_new_tab() |
| 65 | + |
| 66 | + # close the first 6 tabs |
| 67 | + with driver.context(driver.CONTEXT_CHROME): |
| 68 | + x_icon = tabs.get_element("tab-x-icon", multiple=True) |
| 69 | + for i in range(num_tabs): |
| 70 | + x_icon[i].click() |
| 71 | + |
| 72 | + panel_ui.open_panel_menu() |
| 73 | + |
| 74 | + # go into the history tab |
| 75 | + panel_ui.get_element("panel-ui-history").click() |
| 76 | + |
| 77 | + # check for history |
| 78 | + recently_visited_container = panel_ui.get_element( |
| 79 | + "panel-ui-history-recent-history-container" |
| 80 | + ) |
| 81 | + recently_visited_items = panel_ui.get_element( |
| 82 | + "panel-ui-history-recent-history-item", |
| 83 | + multiple=True, |
| 84 | + parent_element=recently_visited_container, |
| 85 | + ) |
| 86 | + |
| 87 | + # ensure no actual items are there |
| 88 | + assert len(recently_visited_items) == 1 |
| 89 | + assert recently_visited_items[0].get_attribute("label") == "(Empty)" |
0 commit comments