Skip to content

Commit f0b7a19

Browse files
committed
correct test_set_multiple_files
1 parent 5ed8102 commit f0b7a19

File tree

1 file changed

+4
-108
lines changed

1 file changed

+4
-108
lines changed

py/test/selenium/webdriver/common/bidi_input_tests.py

Lines changed: 4 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,10 @@ def test_set_files(driver, pages):
283283
os.unlink(temp_file_path)
284284

285285

286-
def test_set_multiple_files(driver, pages):
287-
"""Test setting multiple files on file input element."""
288-
pages.load("formPage.html")
286+
def test_set_multiple_files(driver):
287+
"""Test setting multiple files on a file input element with 'multiple' attribute using BiDi."""
288+
driver.get("data:text/html,<input id=upload type=file multiple />")
289289

290-
# Use the same upload element but try to set multiple files
291-
# Note: The HTML file only has one file input, so this test demonstrates
292-
# the API even though the element may not support multiple files
293290
upload_element = driver.find_element(By.ID, "upload")
294291

295292
# Create temporary files
@@ -305,18 +302,10 @@ def test_set_multiple_files(driver, pages):
305302
element_id = upload_element._id
306303
element_ref = {"sharedId": element_id}
307304

308-
# Set multiple files using BiDi (this might fail if element doesn't support multiple)
309-
# The test mainly demonstrates the API
310305
driver.input.set_files(driver.current_window_handle, element_ref, temp_files)
311306

312-
# Verify files were set (exact verification depends on browser implementation)
313307
value = upload_element.get_attribute("value")
314-
assert value != "" # Should have some value now
315-
316-
except Exception:
317-
# This might fail if the element doesn't support multiple files
318-
# which is expected for the current HTML
319-
pass
308+
assert value != ""
320309

321310
finally:
322311
# Clean up temp files
@@ -360,99 +349,6 @@ def test_release_actions(driver, pages):
360349
WebDriverWait(driver, 5).until(lambda d: "b" in input_element.get_attribute("value"))
361350

362351

363-
def test_pause_action_without_duration(driver):
364-
"""Test pause action without explicit duration."""
365-
pause = PauseAction()
366-
assert pause.type == "pause"
367-
assert pause.duration is None
368-
369-
pause_dict = pause.to_dict()
370-
assert pause_dict["type"] == "pause"
371-
assert "duration" not in pause_dict
372-
373-
374-
def test_pause_action_with_duration(driver):
375-
"""Test pause action with explicit duration."""
376-
pause = PauseAction(duration=1000)
377-
assert pause.duration == 1000
378-
379-
pause_dict = pause.to_dict()
380-
assert pause_dict["type"] == "pause"
381-
assert pause_dict["duration"] == 1000
382-
383-
384-
def test_pointer_parameters_validation():
385-
"""Test pointer parameters validation."""
386-
# Valid pointer type
387-
params = PointerParameters(pointer_type=PointerType.MOUSE)
388-
assert params.pointer_type == PointerType.MOUSE
389-
390-
# Invalid pointer type should raise ValueError
391-
with pytest.raises(ValueError, match="Invalid pointer type"):
392-
PointerParameters(pointer_type="invalid")
393-
394-
395-
def test_pointer_common_properties_validation():
396-
"""Test pointer common properties validation."""
397-
# Valid properties
398-
props = PointerCommonProperties(
399-
width=2, height=2, pressure=0.5, tangential_pressure=0.3, twist=180, altitude_angle=0.5, azimuth_angle=3.14
400-
)
401-
assert props.width == 2
402-
assert props.pressure == 0.5
403-
404-
# Invalid width
405-
with pytest.raises(ValueError, match="width must be at least 1"):
406-
PointerCommonProperties(width=0)
407-
408-
# Invalid pressure
409-
with pytest.raises(ValueError, match="pressure must be between 0.0 and 1.0"):
410-
PointerCommonProperties(pressure=1.5)
411-
412-
# Invalid twist
413-
with pytest.raises(ValueError, match="twist must be between 0 and 359"):
414-
PointerCommonProperties(twist=360)
415-
416-
417-
def test_element_origin_creation():
418-
"""Test ElementOrigin creation and serialization."""
419-
element_ref = {"sharedId": "test-element-id"}
420-
origin = ElementOrigin(element_ref)
421-
422-
assert origin.type == "element"
423-
assert origin.element == element_ref
424-
425-
origin_dict = origin.to_dict()
426-
assert origin_dict["type"] == "element"
427-
assert origin_dict["element"] == element_ref
428-
429-
430-
def test_source_actions_serialization():
431-
"""Test that source actions serialize correctly to dictionaries."""
432-
# Test KeySourceActions
433-
key_actions = KeySourceActions(
434-
id="test-keyboard", actions=[KeyDownAction(value="a"), PauseAction(duration=100), KeyUpAction(value="a")]
435-
)
436-
437-
key_dict = key_actions.to_dict()
438-
assert key_dict["type"] == "key"
439-
assert key_dict["id"] == "test-keyboard"
440-
assert len(key_dict["actions"]) == 3
441-
442-
# Test PointerSourceActions
443-
pointer_actions = PointerSourceActions(
444-
id="test-mouse",
445-
parameters=PointerParameters(pointer_type=PointerType.MOUSE),
446-
actions=[PointerMoveAction(x=100, y=200), PointerDownAction(button=0), PointerUpAction(button=0)],
447-
)
448-
449-
pointer_dict = pointer_actions.to_dict()
450-
assert pointer_dict["type"] == "pointer"
451-
assert pointer_dict["id"] == "test-mouse"
452-
assert "parameters" in pointer_dict
453-
assert len(pointer_dict["actions"]) == 3
454-
455-
456352
@pytest.mark.parametrize("multiple", [True, False])
457353
@pytest.mark.xfail_firefox(reason="File dialog handling not implemented in Firefox yet")
458354
def test_file_dialog_event_handler_multiple(driver, multiple):

0 commit comments

Comments
 (0)