Python 3, Selenium, Os - How To Upload All Images In Folder
I'm making an application (Windows 10 and selenium chromedriver) that makes an ad for me on an ad website, with all the details, and now I want to get to the part of uploading imag
Solution 1:
Tested locally not on the server.
# get the button element
ele = driver.find_element_by_id("ImageUploadButton")
# add a hidden file input ( might have to change the onchange event based on the events associated to the button in above line as you don't have a form)
driver.execute_script("var x= document.createElement('INPUT');x.setAttribute('type', 'file'); x.setAttribute('onchange','this.form.submit()');x.setAttribute('hidden', 'true'); arguments[0].appendChild(x);",ele)
# send the picture path here ( this should upload the file)
driver.find_element_by_xpath("//input[@type='file']").send_keys("picture path should go here")
Post a Comment for "Python 3, Selenium, Os - How To Upload All Images In Folder"