WatiN FileUpload 按打开按钮即可快速

发布于 2024-10-18 07:07:39 字数 838 浏览 2 评论 0原文


我的文件上传窗口出现问题。当我第一次使用它时,它工作得很好,但是当我调用相同的功能来打开和上传文件时,打开按钮(在“选择要上传的文件”对话框中)被快速按下。因此测试无法写入超过设置的文件的完整路径,因此我无法打开该文件。
该功能的源代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行雁书 2024-10-25 07:07:39

您可能会发现文件上传对话框处理程序正在不同的线程上运行,这就是您没有机会输入文本的原因。

如果情况并非如此,并且确实是对话框处理程序的问题,那么我将获取 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文