Skip to content

Commit b83ef9b

Browse files
authored
Update file upload (#178)
Co-authored-by: qahive-art <atthaboon.s@qahive.com>
1 parent 66bdba9 commit b83ef9b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Examples/state-admin.json
3333
Examples/test-report/
3434
test-report/
3535
puppeteer-screenshot-.*.png
36+
puppeteer-screenshot-1.png

PuppeteerLibrary/playwright/async_keywords/playwright_formelement.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ async def download_file(self, locator: str, timeout=None):
3434

3535
async def upload_file(self, locator: str, file_path: str):
3636
file_path = str2str(file_path)
37-
handle = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
38-
await handle.set_input_files(file_path)
37+
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
38+
async with self.library_ctx.get_current_page().get_page().expect_file_chooser() as fc_info:
39+
await element.click()
40+
file_chooser = await fc_info.value
41+
await file_chooser.set_files(file_path)
3942

4043
async def _clear_input_text(self, selenium_locator):
4144
await self.library_ctx.get_current_page().click_with_selenium_locator(selenium_locator, {'click_count': 3})

0 commit comments

Comments
 (0)