Issue
Good evening,
I am currently working on a automated bot that uploads ebay ad's (if you want to call it like that).
I am currently struggling to upload a picture.
This is how it looks like and when you press on the camera you need to go through your files and select the picture.
My question:
How can i insert the Picture with python selenium.
Background
If someone wants to take a deeper dive on the html what ever, here is the link to the Website i am trying to bot:
Ebay-kleinanzeigen.de
You need to create an account and press on "create an ad" or something simmilar to this.
It should look something like this:
Thanks
Solution
The most easy and widely used way to upload a file with Selenium is not to click the "upload" button you see as a user rather to send that file directly to some specific element on the page. In most cases it will be element located by this XPath: //input[@type='file']
. So if your file location on your PC is something like
path = "C://folder/filename.extension"
you can simply upload it with the following command:
driver.find_element_by_xpath("//input[@type='file']").send_keys(path)
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.