Skip to content

Commit

Permalink
Update file upload (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: qahive-art <atthaboon.s@qahive.com>
  • Loading branch information
atthaboon and atthaboon authored Sep 7, 2022
1 parent 66bdba9 commit b83ef9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Examples/state-admin.json
Examples/test-report/
test-report/
puppeteer-screenshot-.*.png
puppeteer-screenshot-1.png
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ async def download_file(self, locator: str, timeout=None):

async def upload_file(self, locator: str, file_path: str):
file_path = str2str(file_path)
handle = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
await handle.set_input_files(file_path)
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
async with self.library_ctx.get_current_page().get_page().expect_file_chooser() as fc_info:
await element.click()
file_chooser = await fc_info.value
await file_chooser.set_files(file_path)

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

0 comments on commit b83ef9b

Please sign in to comment.