Skip to content

Commit 8d76cc9

Browse files
committed
fix: fix contextmanager for file upload
1 parent d0edfc8 commit 8d76cc9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pydoll/browser/tab.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
WaitElementTimeout,
4242
)
4343
from pydoll.protocol.base import Response
44+
from pydoll.protocol.dom.types import EventFileChooserOpened
4445
from pydoll.protocol.network.responses import GetResponseBodyResponse
4546
from pydoll.protocol.network.types import Cookie, CookieParam, NetworkLog
4647
from pydoll.protocol.page.events import PageEvent
@@ -678,10 +679,11 @@ async def expect_file_chooser(
678679
files: File path(s) for upload.
679680
"""
680681

681-
async def event_handler(event):
682+
async def event_handler(event: EventFileChooserOpened):
683+
file_list = files if isinstance(files, list) else [files]
682684
await self._execute_command(
683-
DomCommands.upload_files(
684-
files=files,
685+
DomCommands.set_file_input_files(
686+
files=file_list,
685687
backend_node_id=event['params']['backendNodeId'],
686688
)
687689
)

pydoll/protocol/dom/types.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,14 @@ class BoxModel(TypedDict):
7979
width: int
8080
height: int
8181
shapeOutside: NotRequired[ShapeOutsideInfo]
82+
83+
84+
class EventFileChooserOpenedParams(TypedDict):
85+
frameId: str
86+
mode: str
87+
backendNodeId: int
88+
89+
90+
class EventFileChooserOpened(TypedDict):
91+
method: str
92+
params: EventFileChooserOpenedParams

0 commit comments

Comments
 (0)