自动拖曳C#中使用Selenium WebDriver删除功能[文件上传] [英] Automate drag & drop functionality [File Upload] using Selenium WebDriver in C#
问题描述
我需要在C#中自动执行拖放功能,但是找不到正确的方法!这是一个文件上传表单,我需要在那里自动执行拖放操作.
I need to automate drag and drop functionality in C# but couldn't find the right way to do it! This is a file upload form and I need to automate drag and drop action there.
以这种方式进行实验:
public void FileAttachment() {
PageObjects.UploadFile.Click();
Driver.Instance.FindElement(By.XPath("//*@id='fileUpload']div")).SendKeys("filepath");
PageObjects.FileUploadSend.Click();
}
帮我穿过这块岩石!
推荐答案
您是否正在使用HTML5拖放功能?我也遇到了同样的问题,从几年前开始,从各个线程来看,使用HTML5拖放操作一直存在错误,并且似乎没有得到解决.我找到了github实现的一些替代方法,尽管它们需要JavaScript执行,以及将代码转换为C#:
Are you using HTML5 drag and drop? I am stuck with the same issue, and seeing from the various threads, using HTML5 drag and drop has been bugged since few years ago and doesn't seem to be fixed. I found some alternative ways from github achieves, they require javascript execution though, as well as translating the code to C# : http://elementalselenium.com/tips/39-drag-and-drop
这篇关于自动拖曳C#中使用Selenium WebDriver删除功能[文件上传]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!