I have such HTML:
<a id="buttonToUpload" class="btn-pink medium" href="#">
<span class="icon-arrow-right">upload photo</span>
</a>
<form id="form1" enctype="multipart/form-data">
<input id="uploadImage" type="file" accept="image/png, image/gif, image/jpeg, image/jpg" style="visibility: hidden">
</form>
Pressing on raise system dialog for choosing file, which I can't access via webdriver. I tried send_keys() directly to but it raises ElementNotVisibleException. So how can I upload photo there? Actual code:
driver = webdriver.Firefox()
driver.get('http://www........')
upload_input = driver.find_element_by_id('uploadImage')
upload_input.send_keys(os.getcwd()+'/image.jpg')
Solved with this:
driver.execute_script("document.getElementById('uploadImage').style.visibility='visible'")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With