如何上传文件(图片)与硒,蟒蛇 [英] How to upload file ( picture ) with selenium, python
问题描述
我尝试了很多东西,但没有任何工作。我很绝望。
上传看起来像这样:
http://img21.imageshack.us/img21/1954/uploadgr.jpg
感谢您的帮助
Filip。
上传输入控件打开一个本地对话框(这是由浏览器完成的),所以点击控件或通过Selenium浏览按钮将弹出对话框,测试将挂起。
解决方法是通过JavaScript设置上传输入的值(在Java中是通过JavascriptExecutor完成),然后提交表单。
请参阅 is there any possibility how to upload on web picture with selenium testing tool ? I am using python. I tryed many things, but nothing didnt work. I am desperate. Upload looks like this : http://img21.imageshack.us/img21/1954/uploadgr.jpg Thank you for your help Filip. Upload input control opens a native dialog (it is done by browser) so clicking on the control or browse button via Selenium will just pop the dialog and the test will hang. The workaround is to set the value of the upload input via JavaScript (in Java it is done via JavascriptExecutor) and then submit the form. See this question for sample in C#, I am sure there's also a way to call JavaScript in Python but I never used Selenium Python bindings 这篇关于如何上传文件(图片)与硒,蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!