【问题标题】:Can't automatically choose file on <input type="file"> by using Selenium Webdriver无法使用 Selenium Webdriver 在 <input type="file"> 上自动选择文件
【发布时间】:2018-05-24 04:57:13
【问题描述】:

我运行了 webdriver,一切都很好,直到操作系统文件浏览器弹出窗口和 webdriver 无法与之交互,因此它无法自动选择文件浏览器上的文件。 那么如何在文件浏览器上自动选择文件呢?

【问题讨论】:

  • 你能分享你的代码吗?
  • 您遇到的错误是什么,请与您到目前为止所尝试的内容一起分享。

标签: java html selenium selenium-webdriver selenium-chromedriver


【解决方案1】:

您是否点击了上传按钮?

相反,您需要查找类型为“文件”的输入元素。找到此位置后,使用文件位置执行发送密钥命令。

例如

driver.findElement(By.xpath("//input[@type='file']")).sendKeys("File Location") ;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    • 2010-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-24
    • 1970-01-01
    相关资源
    最近更新 更多