使用Selenium的边缘上传文件控件 [英] Edge Upload File control using Selenium

查看:73
本文介绍了使用Selenium的边缘上传文件控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to upload a file using Selenium Webdriver on the Edge browser, and yes I have downloaded EdgeDriver and installed the MSI for testing Edge. Clicking on elements on the screen from within the Edge browser works fine. The problem is the upload file control. My code is as follows:

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以编程方式使用控件上载文件.没有错误,只是不单击将文本发送到文件上载控件".什么都不执行:

The code above works for Chrome and Firefox, but does not work for Edge. This is a ReactJS web app. I have tried the suggestions below that are similar to my code above and I cannot seem to upload a file using the control programmatically from Selenium Webdriver. There is no error given it just does not click on send text to the file upload control. Nothing is executed:

如何使用Selenium Webdriver上传文件?

边缘的文件控制

DOM上传控件边缘

推荐答案

不幸的是,此功能尚未添加到边缘webdriver中.我遇到了同样的问题,还没有找到合适的解决方案.一种(公认不理想的)解决方案是使用AutoIt自动将文件上传到边缘. 此问题有多个报告,但这是其中一个最新报告显示这与边缘驱动程序有关.

Unfortunately this feature has not been added to the edge webdriver yet. I've run into the same problem and have not been able to find a suitable solution yet. One (admitedly not ideal) solution is to use AutoIt to automate the file upload for edge. There are multiple reports of this issue, but here's one of the latest reports showing that its an issue with the edge driver.

这篇关于使用Selenium的边缘上传文件控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆