Skip to content

Commit f187bb3

Browse files
committed
finishes intervention card
1 parent 7385970 commit f187bb3

File tree

4 files changed

+123
-11
lines changed

4 files changed

+123
-11
lines changed

modules/browser_object_autofill_popup.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ def verify_no_popup_panel(self):
2626
element = self.get_element("autofill-panel")
2727
self.expect_not(EC.element_to_be_clickable(element))
2828

29-
def hover_over_element(self, element: str):
30-
"""
31-
Hover over the specified element.
32-
Parameters: element (str): The element to hover over.
33-
"""
34-
with self.driver.context(self.driver.CONTEXT_CHROME):
35-
self.actions.move_to_element(element).perform()
36-
return self
37-
3829
def get_nth_element(self, index: str) -> WebElement:
3930
"""
4031
Get the nth element from the autocomplete list.

modules/data/navigation.components.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"refresh-intervention-card": {
4545
"selectorData": "div[tip-type=\"intervention_refresh\"]",
4646
"strategy": "css",
47-
"groups": []
47+
"groups": [
48+
"doNotCache"
49+
]
4850
},
4951

5052
"fx-refresh-text": {
@@ -71,6 +73,12 @@
7173
"groups": []
7274
},
7375

76+
"fx-refresh-menu-get-help-item-get-help": {
77+
"selectorData": "urlbarView-result-menuitem",
78+
"strategy": "class",
79+
"groups": []
80+
},
81+
7482
"search-engine-suggestion-row": {
7583
"selectorData": "div[class=\"urlbarView-row\"][type=\"search_engine\"]",
7684
"strategy": "css",
@@ -124,6 +132,12 @@
124132
"selectorData": "downloads-button",
125133
"strategy": "id",
126134
"groups": []
135+
},
136+
137+
"search-results-container": {
138+
"selectorData": "urlbar-results",
139+
"strategy": "id",
140+
"groups": []
127141
}
128142

129143
}

modules/page_base.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
from copy import deepcopy
77
from pathlib import Path
8-
from typing import Union
8+
from typing import List, Union
99

1010
from pypom import Page
1111
from selenium.common.exceptions import NoSuchElementException, TimeoutException
@@ -437,6 +437,32 @@ def hide_popup_by_child_node(self, node: WebElement, chrome=False) -> Page:
437437
else:
438438
self.driver.execute_script(script, node)
439439

440+
def hover_over_element(self, element: WebElement, chrome=False):
441+
"""
442+
Hover over the specified element.
443+
Parameters: element (str): The element to hover over.
444+
445+
Default tries to hover something in the chrome context
446+
"""
447+
if chrome:
448+
with self.driver.context(self.driver.CONTEXT_CHROME):
449+
self.actions.move_to_element(element).perform()
450+
else:
451+
self.actions.move_to_element(element).perform()
452+
return self
453+
454+
def get_all_children(self, element: WebElement, chrome=False) -> List[WebElement]:
455+
"""
456+
Gets all the children of a webelement
457+
"""
458+
children = None
459+
if chrome:
460+
with self.driver.context(self.driver.CONTEXT_CHROME):
461+
children = element.find_elements(By.XPATH, "./*")
462+
else:
463+
children = element.find_elements(By.XPATH, "./*")
464+
return children
465+
440466
@property
441467
def loaded(self):
442468
"""
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import pytest
2+
from selenium.webdriver import Firefox
3+
4+
from modules.browser_object import Navigation
5+
6+
LIGHT_MODE_BEFORE_RBG_VALUE = "rgba(207, 207, 216, 0.33)"
7+
DARK_MODE_BEFORE_RGB_VALUE = "rgba(0, 0, 0, 0.33)"
8+
9+
LIGHT_MODE_AFTER_RGB_VALUE = "color(srgb 0 0 0 / 0.6)"
10+
DARK_MODE_AFTER_RGB_VALUE = "color(srgb 0.984314 0.984314 0.996078 / 0.6)"
11+
12+
13+
# Set search region
14+
@pytest.fixture()
15+
def add_prefs():
16+
return [
17+
("browser.search.region", "US"),
18+
]
19+
20+
21+
def test_intervention_card_refresh(driver: Firefox):
22+
"""
23+
C1365204.1: regular firefox, check the intervention card
24+
"""
25+
# instantiate objects and type in search bar
26+
nav = Navigation(driver).open()
27+
nav.set_awesome_bar()
28+
nav.type_in_awesome_bar("refresh firefox")
29+
30+
# get relevant items
31+
refresh_text = nav.get_element("fx-refresh-text")
32+
refresh_button = nav.get_element("fx-refresh-button")
33+
help_menu_button = nav.get_element("fx-refresh-menu")
34+
35+
# ensure the text is correct
36+
assert (
37+
refresh_text.get_attribute("innerHTML")
38+
== "Restore default settings and remove old add-ons for optimal performance."
39+
)
40+
41+
# ensure the color before hover
42+
button_background = refresh_button.value_of_css_property("background-color")
43+
assert (
44+
button_background == LIGHT_MODE_BEFORE_RBG_VALUE
45+
or button_background == DARK_MODE_BEFORE_RGB_VALUE
46+
)
47+
nav.hover_over_element(refresh_button, chrome=True)
48+
49+
# ensure there is a hover state
50+
new_button_background = refresh_button.value_of_css_property("background-color")
51+
assert (
52+
new_button_background == LIGHT_MODE_AFTER_RGB_VALUE
53+
or new_button_background == DARK_MODE_AFTER_RGB_VALUE
54+
)
55+
56+
# repeated from before but with the 3 dots menu button
57+
help_menu_background = help_menu_button.value_of_css_property("background-color")
58+
assert (
59+
help_menu_background == LIGHT_MODE_BEFORE_RBG_VALUE
60+
or help_menu_background == DARK_MODE_BEFORE_RGB_VALUE
61+
)
62+
assert help_menu_button.get_attribute("open") is None
63+
nav.hover_over_element(help_menu_button, chrome=True)
64+
65+
new_help_menu_background = help_menu_button.value_of_css_property(
66+
"background-color"
67+
)
68+
assert (
69+
new_help_menu_background == LIGHT_MODE_AFTER_RGB_VALUE
70+
or new_help_menu_background == DARK_MODE_AFTER_RGB_VALUE
71+
)
72+
73+
# ensure the popup appears
74+
help_menu_button.click()
75+
assert help_menu_button.get_attribute("open") == "true"
76+
assert nav.get_element("fx-refresh-menu-get-help-item-get-help") is not None
77+
78+
# get the number of options (search results)
79+
search_results_container = nav.get_element("search-results-container")
80+
search_results = nav.get_all_children(search_results_container, chrome=True)
81+
assert len(search_results) == 2

0 commit comments

Comments
 (0)