From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Upload files

Upload files

In this lesson, we'll go ahead and learn how to upload files inside of a file input field. So let's go ahead and inspect the same. You can see it as a input field with the type specified as file, which is a file input field. And it also has a label so we can select it using its label. So we can say something like file input, and then we can use the get by label input field and type out its name. That is default file input example. And great, we have selected it. And to actually upload a file, what we have to do is use the file input element and call the set input files method. So we can provide the destination or the path to a file we want to upload. And this is running on this location right here, that is x slash opera. And here I have some files, let's say I like to upload this file dot text. So what I can do is simply save file dot text. If I hit enter, you can see file or text is loaded. And because it is set input files, we can go ahead and upload multiple files as well. So…

Contents