Skip to content

Commit c54f106

Browse files
committed
rely on bgColor
1 parent 41523e7 commit c54f106

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

tests/e2e-playwright/tests/tip/test_ti_plan.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import logging
1111
import re
12+
import time
1213
from collections.abc import Callable
1314
from dataclasses import dataclass
1415
from pathlib import Path
@@ -224,21 +225,26 @@ def test_classic_ti_plan( # noqa: PLR0915
224225
assert not ws_info.value.is_closed()
225226
restartable_jlab_websocket = RobustWebSocket(page, ws_info.value)
226227

227-
with (
228-
log_context(logging.INFO, "Run optimization"),
229-
restartable_jlab_websocket.expect_event(
230-
"framereceived",
231-
_JLabWebSocketWaiter(
232-
expected_header_msg_type="stream",
233-
expected_message_contents="All results evaluated",
234-
),
235-
timeout=_JLAB_RUN_OPTIMIZATION_MAX_TIME
236-
+ _JLAB_RUN_OPTIMIZATION_APPEARANCE_TIME,
237-
),
238-
):
239-
ti_iframe.get_by_role("button", name="Run Optimization").click(
240-
timeout=_JLAB_RUN_OPTIMIZATION_APPEARANCE_TIME
241-
)
228+
with log_context(logging.INFO, "Run optimization") as ctx:
229+
run_button = ti_iframe.get_by_role("button", name="Run Optimization")
230+
run_button.click(timeout=_JLAB_RUN_OPTIMIZATION_APPEARANCE_TIME)
231+
232+
start = time.time()
233+
success = False
234+
while (
235+
time.time() - start < _JLAB_RUN_OPTIMIZATION_MAX_TIME / 1000
236+
): # Convert ms to seconds
237+
bg_color = run_button.evaluate(
238+
"el => getComputedStyle(el).backgroundColor"
239+
)
240+
if bg_color == "rgb(0, 128, 0)":
241+
ctx.logger.info("Optimization finished!")
242+
success = True
243+
break
244+
time.sleep(2)
245+
246+
if not success:
247+
ctx.logger.info("Optimization did not finish in time.")
242248

243249
with log_context(logging.INFO, "Create report"):
244250
with log_context(

0 commit comments

Comments
 (0)