【问题标题】:How to handle FolderBrowserDialog using Selenium如何使用 Selenium 处理 FolderBrowserDialog
【发布时间】:2015-05-08 19:15:15
【问题描述】:

我看到了与文件上传相关的问题。但我拥有的是FolderBrowserDialog。谁能帮我弄清楚 selenium 如何处理这个自动化?

我正在尝试做这样的事情 -

public IWebElement BrowseWindow
    {
        get { return WebDriverProvider.Driver.WaitForAndFindElement(By.Name("FolderBrowserDialog")); }
    }

【问题讨论】:

标签: c# winforms selenium


【解决方案1】:

因为,Selenium 是一个浏览器自动化工具,它不具备浏览器之外的功能。有一些第三方库,如 AutoIt 可以帮助您进行文件浏览或上传,但 Selenium 不提供本机支持。但是,Selenium 支持使用 sendKeys() 上传文件,如果是这种情况。

WebElement file = driver.findElement(By.name("name of file input tag"));
file.sendKeys("file path with extension");

附带说明,如果在 FF 或 Chrome 上完成,隐藏文件输入标记仍可与 sendKeys 一起使用。 IE 仍然不支持文件上传的隐藏文件输入标签。见this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 2020-11-05
    • 2019-03-04
    • 2021-07-20
    • 2023-04-11
    • 1970-01-01
    • 2022-09-23
    相关资源
    最近更新 更多