Which attributes should be changed to allow for image upload via Selenium
As per your code attempts seems we can't do much with the second <input>
tag. But you can simply remove the attribute style="display: none;" from the first <input>
tag and try to invoke send_keys()
method as follows :
element = driver.find_element_by_xpath("//input[@id='FileNameUpload' and @name='FileNameUpload']")driver.execute_script("arguments[0].removeAttribute('style')", element)driver.find_element_by_xpath("//input[@id='FileNameUpload' and @name='FileNameUpload']").send_keys("path_to_my_image")
Note : path_to_my_image must be the absolute path of the image file ending with either .jpg, .jpeg, .png, .gif or .bmp extension and must be less then 10240 bytes.