WatiN FileUpload 按打开按钮即可快速
我的文件上传窗口出现问题。当我第一次使用它时,它工作得很好,但是当我调用相同的功能来打开和上传文件时,打开按钮(在“选择要上传的文件”对话框中)被快速按下。因此测试无法写入超过设置的文件的完整路径,因此我无法打开该文件。
该功能的源代码:
public void OpenFileDialogAndUploadCsvFileWithName(string fileName, IE editPage)
{
var fileUploadDialog = editPage.HtmlDialog(Find.ByTitle(PageTitle));
fileUploadDialog.WaitForComplete();
FileUpload fileUpload = fileUploadDialog.FileUpload(Find.ById(new Regex("_FileUpload")));
fileUpload.Set(fileName);
Image image = fileUploadDialog.Image(Find.BySrc(new Regex("/icons/upload.png")));
Element parentElement = image.Parent;
parentElement.FireEventNoWait("onmouseup");
parentElement.FireEventNoWait("onmousedown");
}
上传文件对话框从 Internet Explorer 模态对话框窗口打开。
I have the Problem with the File Upload window. When I used it the first time it works perfect but when I call the same functionality to open and upload a File the open button (in the "Choose File to Upload" Dialog) is pressed to fast. So the Test can not write the complete path of the File over set and so the I can not open the File.
The Source Code of the function:
public void OpenFileDialogAndUploadCsvFileWithName(string fileName, IE editPage)
{
var fileUploadDialog = editPage.HtmlDialog(Find.ByTitle(PageTitle));
fileUploadDialog.WaitForComplete();
FileUpload fileUpload = fileUploadDialog.FileUpload(Find.ById(new Regex("_FileUpload")));
fileUpload.Set(fileName);
Image image = fileUploadDialog.Image(Find.BySrc(new Regex("/icons/upload.png")));
Element parentElement = image.Parent;
parentElement.FireEventNoWait("onmouseup");
parentElement.FireEventNoWait("onmousedown");
}
The Upload File Dialog is open from Internet Explorer Modal Dialog Window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会发现文件上传对话框处理程序正在不同的线程上运行,这就是您没有机会输入文本的原因。
如果情况并非如此,并且确实是对话框处理程序的问题,那么我将获取 fileUploadDialog 处理程序的代码并创建我自己的自定义较慢版本。
You might find that the file upload dialog handler is running on a different thread, and that is why you don't get a chance to enter your text.
If that is not he case, and it really is a problem with the dialog handler then I would grab the code for the fileUploadDialog handler and create my own, custom, slower version.