MCPcopy Index your code
hub / github.com/microsoft/playwright-python / test_should_upload_the_file

Function test_should_upload_the_file

tests/async/test_input.py:34–52  ·  view source on GitHub ↗
(page: Page, server: Server)

Source from the content-addressed store, hash-verified

32
33
34async def test_should_upload_the_file(page: Page, server: Server) -> None:
35 await page.goto(server.PREFIX + "/input/fileupload.html")
36 file_path = os.path.relpath(FILE_TO_UPLOAD, os.getcwd())
37 input = await page.query_selector("input")
38 assert input
39 await input.set_input_files(file_path)
40 assert await page.evaluate("e => e.files[0].name", input) == "file-to-upload.txt"
41 assert (
42 await page.evaluate(
43 """e => {
44 reader = new FileReader()
45 promise = new Promise(fulfill => reader.onload = fulfill)
46 reader.readAsText(e.files[0])
47 return promise.then(() => reader.result)
48 }""",
49 input,
50 )
51 == "contents of the file\n"
52 )
53
54
55async def test_should_work(page: Page, assetdir: Path) -> None:

Callers

nothing calls this directly

Calls 4

gotoMethod · 0.45
query_selectorMethod · 0.45
set_input_filesMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected