Which attributes should be changed to allow for image upload via Selenium Which attributes should be changed to allow for image upload via Selenium selenium selenium

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.


In <input> tags the text is in the value attribute. Setting it with JavaScript should work

upload_button = el_id('FileNameUpload')browser.execute_script("arguments[0].value = 'arguments[1]';", upload_button, path_to_my_image)