【发布时间】:2016-11-10 14:22:12
【问题描述】:
我有点不知道如何克服这个障碍。我正在尝试为 Kijiji 制作一个转发器,但是当我在 Mac 上时,我被困在如何处理文件上传上。我试着做
driver.find_element_by_id('ImageUploadButton').send_keys(image)
但这似乎没有任何作用,我相信这可能是因为 kijiji 的特殊文件上传,但我不知道如何克服这个障碍。
以前有人做过吗?
他们“查看源代码”页面上的代码:
<div id="ImageUpload" class="clearfix form-section placeholders">
<p class="images-title">Add at least one photo. Use more to show different angles and 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 and Drop</h3>
<p>Drag and drop to change the order of your pictures.</p>
</div>
</div>
<div id="FileInputWrapper" class="file-input-wrapper">
<input type="hidden" name="file" id="FileUploadInput" >
<h3>Get at least twice the number of replies by uploading images</h3>
<p>You can upload a maximum of <span id="MaxImages">10</span> photos, that are at least 300px wide or tall (we recommend at 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>
【问题讨论】:
-
为文件输入元素提供
HTML代码 -
这是它的截图。 imgur.com/a/BRueF
-
我很确定您不能将文本发送到
button类型的元素。检查你的页面元素<input type=file">
标签: python python-2.7 selenium