Python - Selenium: How can I upload File without Type: File

146 Views Asked by At

I´m trying currently upload a picture with Selenium to a site.I have tried

sendkeys(doesnt work because Type: File is missing), autoit(work but I cannot change the Code and Fileurl in Python)

and some other but nothing work for me.

This is the Html-Code from the button:

<div class="Polaris-Page-Header__RightAlign_1ok1p"><div class="Polaris-Page-Header__PrimaryActionWrapper_w8or9"><div class="Polaris-Box_375yx Polaris-Box--printHidden_15ag0"><button class="Polaris-Button_r99lw Polaris-Button--primary_7k9zs" type="button"><span class="Polaris-Button__Content_xd1mk"><span class="Polaris-Button__Text_yj3uv">Dateien hochladen</span></span></button></div></div></div>

What can I use in this case or can I use Sendkey somehow?

Thank you.

1

There are 1 best solutions below

0
VigneshKannan On

You can only send the data to an input tag. On the button tag, you can only click it. So to send your file to the site, inspect the site, search for the file input tag, and get its xpath or css selector to send the file. You can use send_keys("path/to/file") to upload the file in the input tag.

Remember, you can only upload a file in the input tag.