Skip to content

Commit 721b335

Browse files
Refactor Playwright test for exporting track statistics to use marker-based element selection; add MARKER_BUTTON_EXPORT_TRACK_STATISTICS.
1 parent c4c5abe commit 721b335

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

OTAnalytics/plugin_ui/nicegui_gui/pages/analysis_form/container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
ResourceManager,
1111
)
1212
from OTAnalytics.plugin_ui.nicegui_gui.nicegui.elements.button_form import ButtonForm
13+
from OTAnalytics.plugin_ui.nicegui_gui.test_constants import TEST_ID
14+
15+
MARKER_BUTTON_EXPORT_TRACK_STATISTICS = "button-export-track-statistics"
1316

1417

1518
class AnalysisForm(ButtonForm, AbstractFrame):
@@ -57,7 +60,7 @@ def build(self) -> None:
5760
AnalysisKeys.BUTTON_TEXT_EXPORT_TRACK_STATISTICS
5861
),
5962
on_click=self._viewmodel.export_track_statistics,
60-
)
63+
).props(f"{TEST_ID}={MARKER_BUTTON_EXPORT_TRACK_STATISTICS}")
6164

6265
def get_general_buttons(self) -> list[Button]:
6366
general_buttons = []

tests/acceptance/test_export_track_statistics.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
import pytest
1515
from playwright.sync_api import Page # type: ignore
1616

17-
from OTAnalytics.application.resources.resource_manager import (
18-
AnalysisKeys,
19-
ResourceManager,
17+
from OTAnalytics.application.resources.resource_manager import ResourceManager
18+
from OTAnalytics.plugin_ui.nicegui_gui.pages.analysis_form.container import (
19+
MARKER_BUTTON_EXPORT_TRACK_STATISTICS,
2020
)
2121
from tests.acceptance.conftest import PLAYWRIGHT_VISIBLE_TIMEOUT_MS, NiceGUITestServer
2222
from tests.utils.playwright_helpers import (
2323
compare_csv_files,
2424
export_file_via_dialog,
2525
load_main_page,
2626
open_project_otconfig,
27+
search_for_marker_element,
2728
)
2829

2930
playwright = pytest.importorskip(
@@ -68,10 +69,9 @@ def test_export_track_statistics(
6869
page.wait_for_timeout(PLAYWRIGHT_VISIBLE_TIMEOUT_MS)
6970

7071
# Click "Export track statistics ..." button
71-
export_button = page.get_by_text(
72-
resource_manager.get(AnalysisKeys.BUTTON_TEXT_EXPORT_TRACK_STATISTICS),
73-
exact=True,
74-
)
72+
export_button = search_for_marker_element(
73+
page, MARKER_BUTTON_EXPORT_TRACK_STATISTICS
74+
).first
7575
export_button.click()
7676

7777
# Handle export dialog and get output path

0 commit comments

Comments
 (0)