Skip to content

Commit 4455851

Browse files
authored
Bc/deflake tabs (#118)
* attempt to force tab scroll * fix list-all-tabs * remove unstable mark * upgrade ruff; move to main deps * cleanup * move the robot tab 1 to the right
1 parent 8f86e9b commit 4455851

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pypom = "*"
1616
jsonpath-ng = "*"
1717
pillow = "*"
1818
pyfxa = "*"
19+
ruff = "0.5.2"
1920
pytest-rerunfailures = "*"
2021

2122
[dev-packages]
2223
werkzeug = "*"
2324
selenium-wire = "*"
2425
pdoc = "*"
25-
ruff = "0.4.3"
2626
pytest-variables = "*"
2727
taskcluster-taskgraph = "*"

modules/browser_object_tabbar.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -236,22 +236,13 @@ def scroll_on_all_tabs_menu(self, down=True, pixels=200) -> BasePage:
236236
logging.info(f"menu location: {menu.location}")
237237
logging.info(f"menu size: {menu.size}")
238238

239-
def get_bar_y():
240-
return min(
241-
[
242-
menu.size["height"] // 2,
243-
self.driver.get_window_size()["height"] // 2,
244-
]
245-
)
246-
247239
# HACK: Can't figure out what the scrollbox selector is, but it's ~4 pixels
248240
# off the edge of the menu.
249-
x_start = menu.location["x"] + menu.size["width"] - 4
250-
# Grab the middle of the scrollbox area, most likely to hold the bar
251-
y_start = menu.location["y"] + get_bar_y()
241+
x_start = (menu.size["width"] / 2.0) - 4.0
252242
# +Y is down, -Y is up
253243
sign = 1 if down else -1
254-
self.actions.move_by_offset(x_start, y_start)
244+
245+
self.actions.move_to_element_with_offset(menu, x_start, 0)
255246
self.actions.click_and_hold()
256247
self.actions.move_by_offset(0, (sign * pixels))
257248
self.actions.release()

modules/data/tab_bar.components.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
]
7070
},
7171

72+
"all-tabs-menu-scrollbar": {
73+
"selectorData": "#alltabs-popup scrollbox",
74+
"strategy": "css",
75+
"groups": [
76+
"allTabsMenu"
77+
]
78+
},
79+
7280
"all-tabs-entry": {
7381
"selectorData": "all-tabs-item",
7482
"strategy": "class",

tests/tabs/test_list_all_tabs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import logging
2+
from time import sleep
23

34
import pytest
45
from selenium.webdriver import Firefox
56
from selenium.webdriver.common.keys import Keys
67

78
from modules.browser_object import TabBar
89

10+
ROBOT_TAB = 16
11+
912

10-
@pytest.mark.unstable
1113
def test_list_all_tabs(driver: Firefox, screenshot):
1214
"""
1315
C134655, check that the List All Tabs button and menu act as expected.
@@ -16,8 +18,8 @@ def test_list_all_tabs(driver: Firefox, screenshot):
1618
driver.get("about:blank")
1719
for _ in range(17):
1820
tabs.new_tab_by_button()
19-
driver.switch_to.window(driver.window_handles[14])
20-
target_tab = tabs.get_tab(15)
21+
driver.switch_to.window(driver.window_handles[ROBOT_TAB - 1])
22+
target_tab = tabs.get_tab(ROBOT_TAB)
2123
driver.get("about:robots")
2224
with driver.context(driver.CONTEXT_CHROME):
2325
assert tabs.get_tab_title(target_tab).startswith("Gort")
@@ -32,7 +34,7 @@ def test_list_all_tabs(driver: Firefox, screenshot):
3234
for _ in range(40):
3335
tabs.scroll_tabs(tabs.SCROLL_DIRECTION.LEFT)
3436
with driver.context(driver.CONTEXT_CHROME):
35-
if target_tab.location["x"] > driver.get_window_size()["width"]:
37+
if target_tab.location["x"] > (driver.get_window_size()["width"]):
3638
logging.info(
3739
f"Tab location {target_tab.location['x']} should be greater..."
3840
)
@@ -64,7 +66,8 @@ def test_list_all_tabs(driver: Firefox, screenshot):
6466
entry_out_of_view = False
6567
with driver.context(driver.CONTEXT_CHROME):
6668
tabs.open_all_tabs_list()
67-
for _ in range(10):
69+
for _ in range(3):
70+
all_tabs_menu = tabs.get_element("all-tabs-menu")
6871
tabs.scroll_on_all_tabs_menu(down=False)
6972
about_about_location = tabs.get_location_of_all_tabs_entry(selected=True)
7073
all_tabs_menu = tabs.get_element("all-tabs-menu")

tests/tabs/test_navigation_multiple_tabs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from modules.browser_object import TabBar
77

88

9-
@pytest.mark.unstable
109
def test_navigation_multiple_tabs(driver: Firefox):
1110
# open 20 tabs
1211
tabs = TabBar(driver).open()

0 commit comments

Comments
 (0)