13
13
# limitations under the License.
14
14
15
15
import asyncio
16
- from os import path
17
16
import os
18
17
19
18
from playwright .page import Page
20
19
21
- FILE_TO_UPLOAD = path .join (
20
+ FILE_TO_UPLOAD = os . path .join (
22
21
os .path .dirname (os .path .realpath (__file__ )), "assets/file-to-upload.txt"
23
22
)
24
23
27
26
28
27
async def test_should_upload_the_file (page , server ):
29
28
await page .goto (server .PREFIX + "/input/fileupload.html" )
30
- file_path = path .relpath (FILE_TO_UPLOAD , os .getcwd ())
29
+ file_path = os . path .relpath (FILE_TO_UPLOAD , os .getcwd ())
31
30
input = await page .querySelector ("input" )
32
31
await input .setInputFiles (file_path )
33
32
assert await page .evaluate ("e => e.files[0].name" , input ) == "file-to-upload.txt"
@@ -47,7 +46,9 @@ async def test_should_upload_the_file(page, server):
47
46
48
47
async def test_should_work (page ):
49
48
await page .setContent ("<input type=file>" )
50
- await page .setInputFiles ("input" , path .join (__dirname , "assets/file-to-upload.txt" ))
49
+ await page .setInputFiles (
50
+ "input" , os .path .join (__dirname , "assets/file-to-upload.txt" )
51
+ )
51
52
assert await page .evalOnSelector ("input" , "input => input.files.length" ) == 1
52
53
assert (
53
54
await page .evalOnSelector ("input" , "input => input.files[0].name" )
@@ -199,8 +200,8 @@ async def test_should_not_accept_multiple_files_for_single_file_input(page, serv
199
200
try :
200
201
await file_chooser .setFiles (
201
202
[
202
- path .relative ( __dirname + "assets/file-to-upload.txt" ),
203
- path .relative ( __dirname + "assets/pptr.png" ),
203
+ os . path .realpath ( os . path . join ( __dirname , "assets/file-to-upload.txt" ) ),
204
+ os . path .realpath ( os . path . join ( __dirname , "assets/pptr.png" ) ),
204
205
]
205
206
)
206
207
except Exception as exc :
0 commit comments