How to upload file ( picture ) with selenium, python

Filip picture Filip · Dec 29, 2011 · Viewed 77.1k times · Source

How to upload a picture on a web application with the selenium testing tool? I am using python.

I tried many things, but nothing worked.

Answer

karloskar picture karloskar · May 6, 2012

What I'm doing is this (make sure drv is an instance of webdriver):

drv.find_element_by_id("IdOfInputTypeFile").send_keys(os.getcwd()+"/image.png")

and then find your submit button and click it.