使用Selenium进行边缘上传文件控制

时间:2016-08-03 16:27:34

标签: selenium-webdriver

我正在尝试使用Edge浏览器上的Selenium Webdriver上传文件,是的,我已经下载了EdgeDriver并安装了MSI来测试Edge。在Edge浏览器中单击屏幕上的元素可以正常工作。问题是上传文件控制。我的代码如下:

IWebElement fileUploader2 = Browser.Driver.FindElements(By.CssSelector("input[type='file']"))[0];
        fileUploader2.SendKeys(FileUtility.FileUploadsDirectory + "\\sample-account_balances.xlsx");

上述代码适用于Chrome和Firefox,但不适用于Edge。这是一个ReactJS网络应用程序。我尝试过以下类似于上面代码的建议,我似乎无法使用Selenium Webdriver以编程方式上传文件。没有错误,因为它没有点击发送文本到文件上传控件。什么都没有执行:

  

How to upload file using Selenium Webdriver?

File Control on Edge

DOM Upload Control Edge

1 个答案:

答案 0 :(得分:2)

不幸的是,此功能尚未添加到边缘webdriver中。我遇到了同样的问题,但还没有找到合适的解决方案。一个(完全不理想)的解决方案是使用AutoIt自动化边缘文件上传。 There are multiple reports of this issue, but here's one of the latest reports showing that its an issue with the edge driver.

相关问题