【发布时间】:2018-03-15 18:45:26
【问题描述】:
我正在尝试在一个网站上使用 python selenium 上传文件,其 html 中的文件字段如下所示:
<div id="fallback" style="display: none;">
<input id="upload-input" type="file" name="file" multiple="multiple">
<div id="upload-progress" class="upload-progress"></div>
</div>
我正在尝试通过以下代码使元素可见:
elem = driver.find_element_by_xpath("//input[@id='upload-input']")
driver.execute_script("arguments[0].removeAttribute('style')", elem)
elem = driver.find_element_by_xpath("//input[@id='upload-input']")
运行脚本后,脚本停止,不上传文件,也不抛出任何错误。
使用elem.is_displayed()后,我发现即使运行了上面的代码块,元素仍然没有显示。
【问题讨论】: