Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用Selenium WebElement发送密钥上载文件_Python_Selenium - Fatal编程技术网

Python 无法使用Selenium WebElement发送密钥上载文件

Python 无法使用Selenium WebElement发送密钥上载文件,python,selenium,Python,Selenium,我正在尝试使用Selenium自动化文件上传。我正在将文件路径发送到input标记,但它不起作用 选择后,我应该能够在表中看到文件和文件大小,并且,即使列出了文件,其各自的大小也会以零字节的形式列出。然后,单击上载按钮时,不会发生任何事情 文件输入的代码如下所示: <span class="btn btn-success fileinput-button" > <i class="icon-plus icon-white"></i> <s

我正在尝试使用Selenium自动化文件上传。我正在将文件路径发送到
input
标记,但它不起作用

选择后,我应该能够在表中看到文件和文件大小,并且,即使列出了文件,其各自的大小也会以零字节的形式列出。然后,单击上载按钮时,不会发生任何事情

文件输入的代码如下所示:

<span class="btn btn-success fileinput-button" >
    <i class="icon-plus icon-white"></i>
    <span>Add files...&nbsp;&nbsp;&nbsp;</span>
    <input type="file" name="files[]" multiple>
</span>


欢迎任何帮助。提前谢谢

这个网站是什么?它是一个私人网站。您需要凭据才能看到我所说的页面。如果您正在查找我没有指定的内容,您可以告诉我,然后我将为您搜索它。是否已准确传递了abspath(f)?如果我们传递一个实际上不存在的文件,大小是否为0?是的,abspath(f)传递正确。如果我们以某种方式传递了一个不存在的文件,send_keys方法将抛出一个异常。
file_input = driver.wait.until(ec.presence_of_element_located(
            (By.XPATH, "//input[@name=\"files[]\"]")))
file_input.send_keys(abspath(f))