File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,13 @@ def test_python_import(dashboard):
7272
7373 # Check input values
7474 for element_id , expected_value in DISTRIBUTION_VALUES + LATTICE_CONFIGURATION :
75- # Wait for element to be visible before getting its value
75+ # Wait for element to be present in the DOM (doesn't require visibility)
7676 # This is important for CI environments where rendering may be slower
7777 dashboard .sb .wait_for_element_present (element_id , timeout = 10 )
7878
79- actual_value = float (dashboard .sb .get_value (element_id ))
79+ # Use JavaScript to get the value - this works even if the element isn't visible
80+ # (e.g., if it's in a collapsed section)
81+ actual_value = float (dashboard .get_js_input (element_id ))
8082 assert actual_value == pytest .approx (expected_value , ** APPROX_TOL ), (
8183 f"{ element_id } : expected { expected_value } , got { actual_value } "
8284 )
Original file line number Diff line number Diff line change @@ -275,6 +275,25 @@ def get_state(self, state_name):
275275 """
276276 return self .sb .execute_script (js_script , state_name )
277277
278+ def get_js_input (self , element_id : str ):
279+ """
280+ Get input value using JavaScript by accessing the DOM.
281+
282+ Unlike get_value(), this method does not require the element to be visible,
283+ which is useful for elements in collapsed sections or when visibility checks fail.
284+
285+ :param element_id: ID of the input element to read (with or without # prefix).
286+ :return: The value of the input element as a string.
287+ """
288+ # Strip # prefix if present, as getElementById expects just the ID
289+ clean_id = element_id .lstrip ("#" )
290+ js = (
291+ "var el = document.getElementById(arguments[0]);"
292+ "if (!el) { throw new Error('element not found: ' + arguments[0]); }"
293+ "return el.value;"
294+ )
295+ return self .sb .execute_script (js , clean_id )
296+
278297
279298def save_failure_screenshot (
280299 dashboard , request , directory : str | None = None
You can’t perform that action at this time.
0 commit comments