python - Image/file upload on Selenium -
i'm kinda stuck on how past hurdle. i'm trying make reposter kijiji, , i'm stuck on how handle file upload when i'm on mac. tried do
driver.find_element_by_id('imageuploadbutton').send_keys(image)
but doesn't seem anything, believe might because of kijiji's special file upload, i'm not sure how past hurdle.
has done before?
the code on "view source" page:
<div id="imageupload" class="clearfix form-section placeholders"> <p class="images-title">add @ least 1 photo. use more show different angles , details.</p> <ol id="uploadedimages"> </ol> <span class="field-message" data-for="fileuploadinput"></span> <div id="imagedraganddrop" class="clearfix"> <div class="image"></div> <div class="copy"> <h3>drag , drop</h3> <p>drag , drop change order of pictures.</p> </div> </div> <div id="fileinputwrapper" class="file-input-wrapper"> <input type="hidden" name="file" id="fileuploadinput" > <h3>get @ least twice number of replies uploading images</h3> <p>you can upload maximum of <span id="maximages">10</span> photos, @ least 300px wide or tall (we recommend @ least 1000px).</p> <button id="imageuploadbutton" type="button" class="button-update-cancel short file-upload-button"> select images</button> </div> <input type="hidden" name="images"> </div>
you need target "file" input
element instead of button:
image_input = driver.find_element_by_id("fileuploadinput")
now, problem is, element hidden , sending keys not work is. solve problem, need make element visible first:
driver.execute_script("arguments[0].type = 'file';", image_input) image_input.send_keys(image)
Comments
Post a Comment