背景
今天有同学反馈上传playwright
上传文件失败了,使用selenium
也不行。
解决办法
with page.expect_file_chooser() as fc_info:
page.get_by_text("Upload").click()
file_chooser = fc_info.value
file_chooser.set_files("myfile.pdf")
中间遇到的问题
原本想通过录制方法自动生成代码,结果在执行代码的时候提示了:playwright._impl._api_types.Error: Error: Node is not an HTMLInputElement
查看官方文档:
https://playwright.dev/python/docs/input#upload-files
with page.expect_file_chooser() as fc_info:
page.locator("upload").click()
file_chooser = fc_info.value
file_chooser.set_files("myfile.pdf")
标签:playwright,Error,chooser,file,._,page
From: https://www.cnblogs.com/tarzen213/p/16910403.html