Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to select file for input elements? #109

Open
ooker777 opened this issue Nov 12, 2024 · 3 comments
Open

Is it possible to select file for input elements? #109

ooker777 opened this issue Nov 12, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@ooker777
Copy link

I have an HTML input element whose type is file:

<input accept="image/*, image/heic, image/heif" aria-label="Add photo" class="bb bc" type="file" name="file1">

Can I select a file to submit for it? It doesn't seem to be available for ElementHandle. In that case, can you add this one?

@lino-levan
Copy link
Owner

Do you have an example of how you would expect this to work?

@lino-levan lino-levan added the enhancement New feature or request label Nov 12, 2024
@ooker777
Copy link
Author

My goal is to automate posting Facebook posts. There is a problem of clicking the "What's on your mind" input, as it seems that the selectors change every time the page is reloaded. I then use the mobile version m.facebook.com. I want to upload image for the posts. Is it possible?
image

@chaosharmonic
Copy link
Contributor

chaosharmonic commented Jan 5, 2025

So if I'm reading this right, is the problem just that you can't select it by class because the classes keep shuffling?

If that's the case, other properties are accessible from within CSS selectors that should help you here. The selector syntax for this is [attribute="value"]. You should be able to just grab it by type or aria-label this way.

You can add it to an element the way you would with classes or pseudo-selectors -- input[type="file"] for instance -- but you don't strictly have to, and it doesn't sound like you'd need to specify that for the use case you're describing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants