无法使用http://www.dropzonejs.com上的python selenium webdriver上传文件 [英] Unable to upload file using python selenium webdriver on http://www.dropzonejs.com
问题描述
我试图用selenium web驱动上传文件。我得到文件上传对话框在MacOS和Windows中打开,之后没有任何反应。想知道为什么硒不通过上传对话框打开文件?
我使用的Webdriver命令:
<$ p $点击()
wd.get(http://www.dropzonejs.com/)
wd.find_element_by_css_selector(div.dz-message)。点击()
elm = wd.find_element_by_xpath(//输入[@ type ='file'])
elm.send_keys(input.dz-hidden-input /Users/bg/Downloads/YOURFILE.PDF)
elm.submit()
input
元素 - 它会触发一个文件上传对话框,通过硒
。将密钥发送到输入
和提交
形式: < pre $
elm = wd.find_element_by_xpath(//输入[@ type ='file'])
elm.send_keys(/ Users / bg / Downloads / myfile.PDF )
elm.submit()
submit()
在这种情况下在输入元素上调用 - selenium
会找到相应的输入
元素形式并提交。
I am attempting to upload a file using selenium web driver. I get the file upload dialogue box to open in both MacOS and Windows, after which nothing happens. Wondering why selenium does not open the file via the upload dialog?
Webdriver commands I am using:
wd.get("http://www.dropzonejs.com/")
wd.find_element_by_css_selector("div.dz-message").click()
wd.find_element_by_css_selector("input.dz-hidden-input").click()
elm = wd.find_element_by_xpath("//input[@type='file']")
elm.send_keys("/Users/bg/Downloads/YOURFILE.PDF")
elm.submit()
Don't click the file input
element - it would trigger a file upload dialog which you cannot control via selenium
. Send the keys to the input
and submit
the form:
elm = wd.find_element_by_xpath("//input[@type='file']")
elm.send_keys("/Users/bg/Downloads/myfile.PDF")
elm.submit()
submit()
in this case is called on an input element - selenium
would find the corresponding to the input
element form and submit it.
这篇关于无法使用http://www.dropzonejs.com上的python selenium webdriver上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!