按名称从对话框中选择文件 [英] select file from dialog box by name

查看:81
本文介绍了按名称从对话框中选择文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过它的名字从对话框中选择一个文件。这是VS生成的生成脚本。

i'm need to select a file from a dialogbox by it's name. this is the generated scripts VS generate.

public void ChooseFileFolder()

        {

            #region变量声明

            WinListItem uITifsListItem = this.UIChooseFiletoUploadWindow.UIFolderViewWindow.UITifsListItem;

            WinListItem uIItem726598tifListItem = this.UIChooseFiletoUploadWindow.UIFolderViewWindow.UIItem726598tifListItem;

            #endregion



            //双击"Tif"列表项

            //Mouse.DoubleClick(uITifsListItem);

           

            Mouse.Click(uIItem726598tifListItem);                       


        }

public void ChooseFileFolder()
        {
            #region Variable Declarations
            WinListItem uITifsListItem = this.UIChooseFiletoUploadWindow.UIFolderViewWindow.UITifsListItem;
            WinListItem uIItem726598tifListItem = this.UIChooseFiletoUploadWindow.UIFolderViewWindow.UIItem726598tifListItem;
            #endregion

            // Double-Click 'Tif's' list item
            //Mouse.DoubleClick(uITifsListItem);
           
            Mouse.Click(uIItem726598tifListItem);                       
        }

我打算向函数发送我想要打开的文件名,然后脚本应该选择这个文件然后点击打开以便选择,双击也会很好

i'm planning to send to the function the file name i want to open and then the script should chose this file and click open in order to choose , doubleclick also will be fine

谢谢

推荐答案

根据传递的参数为列表项定义搜索属性ChooseFileFolder()方法。类似于 -

Define the search property for your list item based on the passed parameter to the ChooseFileFolder() method. Something like -

 

UITestControl listItemToClick = new UITestControl(this.UIChooseFiletoUploadWindow.UIFolderViewWindow)

UITestControl listItemToClick = new UITestControl(this.UIChooseFiletoUploadWindow.UIFolderViewWindow)

listItemToClick.SearchProperties.Add(" Name",filenamePassedAsParam); //只需确保fileName与列表项控件的Name相同。你可以使用AccExplorer来验证。

listItemToClick.SearchProperties.Add("Name", filenamePassedAsParam); // just ensure the fileName is same as the Name for the list item control. You can verify that using AccExplorer.

listItemToClick.SearchProperties.Add(" ControlType",ControlType.ListItem);

listItemToClick.SearchProperties.Add("ControlType", ControlType.ListItem);

Mouse.Click(listItemToClick );

Mouse.Click(listItemToClick);

 


这篇关于按名称从对话框中选择文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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