【发布时间】:2016-05-06 16:22:34
【问题描述】:
出于测试目的,我需要
- 通过“浏览”窗口选择一个文件 (See screenshot here)
- 点击“打开”(将文件上传到网站),然后
- 点击“上传”。
我如何通过硒做到这一点?因为以下方法不起作用:
# hident2 is the name of "Choose File" element
wd.find_element(By.XPATH("//input[@id='hident2']")).sendKeys("C:\\Users\\file-to-upload.xml");
# input.btn.primary is the name of "Upload" button element**
wd.find_element_by_css_selector("input.btn.primary").click()
我收到以下错误:
TypeError: 'str' 对象不可调用
我做错了什么?
【问题讨论】:
标签: python selenium automation