【发布时间】:2018-05-30 14:43:00
【问题描述】:
我在远程 PC 中启动了一个浏览器,我想从该远程 PC 的本地文件夹中将一个 zip 文件导入我的 Web 应用程序。当我单击“导入”按钮时,它会将我重定向到文件上传,该文件上传不会显示该帧的任何 xpath。我试图获取 Import Button 的 xpath,并使用该对象的本地文件路径的 send_keys,如下所示,
importbutton=driver.find_element_by_xpath(".//*@id='templateUploadButton_label']/img")
importbutton.send_keys("C:/../pathtofile")
但它给了我这样的错误
selenium.common.exceptions.WebDriverException:消息:未知错误: 无法聚焦元素
但是,当我执行 importbutton.click() 时,它会打开文件上传框架。
手动步骤是:点击导入->打开文件上传框架,我选择了一个本地路径并点击打开,如果我们可以继续上传,它会显示一个对话框,我点击是。
【问题讨论】:
标签: python file selenium xpath upload