codyc4321 codyc4321 - 2 months ago 46
Python Question

upload files with selenium webdriver python

I'd like to use webdriver to pick a file but following other answers they do not work. They say just give the button a filepath, and this doesn't do anything. The upload looks like this after clicking the button:

enter image description here

This is what others say to do but doesn't work:

element = driver.find_element_by_name("file")

How can I submit files once I'm in a webdriver instance? Thank you


This problem solved at uploading photos to Craigslist with Python and Selenium

def add_photo(self, filepath_to_photo):
    add_images_button = self.driver.find_element_by_name('upload')
    photo_filepath_input_box = self.driver.find_element_by_xpath("//input[@type='file']")