编码的UI-工具无法识别从VB.net(Framework 4.0)开发的控件 [英] Coded UI- Tool not able to recognize controls developed from VB.net (Framework 4.0)

查看:59
本文介绍了编码的UI-工具无法识别从VB.net(Framework 4.0)开发的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   我正在使用从vb.net开发的ERP应用程序.当我播放从编码的UI"工具开发的脚本时,可以在第一个字段上正确输入数据,但对于第二个控件,光标焦点仍然可以通过替换而停留在第一个字段上 为第二个和其余控件输入的数据.

     I am using ERP application developed from vb.net. When I play-back a script developed from Coded UI tool, the data entered on first field correctly but for the second control also,cursor focus stays on first field itself by replacing data which is entered for the second and remaining controls.

当我在UIMAP.unitest文件下的第一个和第二个控件中选中搜索属性"时,两个控件属性都是相同的(两个控件的控件类型均为Edit Type和TechnologyName = MSAA标识).

When I checked 'Search Properties' for the first and second controls under UIMAP.unitest file, both control properties are identical ( It identified with Control Type=Edit and TechnologyName=MSAA for both controls). 

为了唯一地标识第二个字段,我通过添加控件名称/控件ID修改了第二个控件的搜索属性,但仍然存在一个问题-控件从不关注第二个字段.

In order to identify second field uniquely, I modified second control search properties by adding Control Name/Control ID but still above issue exists-control never focus on second field.

我关注了一些相关的主题,但是问题仍然没有解决.

I followed some of the related thread but still issue is not resolved.

是否需要进行任何设置才能唯一标识控件.我无法更改每个控件的搜索属性,因为这将对我们的ERP应用程序造成巨大的维护.我需要一个解决方案/设置,以便唯一标识控件.

Is there any setting I need to make in order to identify controls uniquely.I cannot change search properties for each controls as it will be huge maintenance for our ERP application. I need a solution/setting so that controls are uniquely identified.

这是示例代码.

//---------------- -------------------------------------------------- ------------

//  <自动生成的>

//     这段代码是由经过编码的UI测试生成器生成的.

//     版本:11.0.0.0

//

//     对此文件所做的更改可能会导致错误的行为,并且如果

//     代码将重新生成.

//  </auto-generated>

//------------------------- -------------------------------------------------- ---

命名空间 CodedUITestProject5

{

    使用 系统;

    使用 System.CodeDom.Compiler;

    使用 System.Collections.Generic;

    使用 System.Drawing;

    使用 System.Text.RegularExpressions;

    使用 System.Windows.Input;

    使用 Microsoft.VisualStudio.TestTools.UITest.Extension;

    使用 Microsoft.VisualStudio.TestTools.UITesting;

    使用 Microsoft.VisualStudio.TestTools.UITesting.WinControls;

    使用 Microsoft.VisualStudio.TestTools.UnitTesting;

    使用 键盘 键盘

    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;

    使用 鼠标 鼠标

    using Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse;

    使用 鼠标按钮 鼠标按钮

    using MouseButtons = System.Windows.Forms.MouseButtons;

   

   

    [ GeneratedCode "已编码 UITest Builder" " 11.0.50727.1"

    [GeneratedCode("Coded UITest Builder", "11.0.50727.1")]

    public partial class UIMap

    public partial class UIMap

    {

      

       

       /// < summary>

        /// <summary>

       ///

        /// RecordedMethod1 - Use 'RecordedMethod1Params' to pass parameters into this method.

       /// </summary>

        /// </summary>

       public void RecordedMethod1()

        public void RecordedMethod1()

       {

#region 变量声明

WinToolBar this .UIERP01CompanyWindow.UITheRibbonPropertyPage.UIRibbonMainToolBar;

            WinToolBar uIRibbonMainToolBar = this.UIERP01CompanyWindow.UITheRibbonPropertyPage.UIRibbonMainToolBar;

WinButton this .UIERP01CompanyWindow.UIRibbonMainToolBar.UITransferButton;

            WinButton uITransferButton = this.UIERP01CompanyWindow.UIRibbonMainToolBar.UITransferButton;

WinTable this .UITransferWindow.UIGrdMainWindow.UIGrdMainTable;

            WinTable uIGrdMainTable = this.UITransferWindow.UIGrdMainWindow.UIGrdMainTable;

WinClient this .UITransferWindow.UIGrdMainWindow.UIHeaderPanelClient;

            WinClient uIHeaderPanelClient = this.UITransferWindow.UIGrdMainWindow.UIHeaderPanelClient;

WinButton this .UIERP01CompanyWindow.UIRibbonMainToolBar1.UINewButton;

            WinButton uINewButton = this.UIERP01CompanyWindow.UIRibbonMainToolBar1.UINewButton;

WinEdit this .UIERP01CompanyWindow.UIGroupCodesGCODWindow.UITheXtraLayoutControlPane.UIIngrpc_fgc_numberEdit;

            WinEdit uIIngrpc_fgc_numberEdit = this.UIERP01CompanyWindow.UIGroupCodesGCODWindow.UITheXtraLayoutControlPane.UIIngrpc_fgc_numberEdit;

WinEdit this .UIERP01CompanyWindow.UIGroupCodesGCODWindow.UITheXtraLayoutControlPane.UIItemEdit;

            WinEdit uIItemEdit = this.UIERP01CompanyWindow.UIGroupCodesGCODWindow.UITheXtraLayoutControlPane.UIItemEdit;

#endregion

//单击"ribbonMain"工具栏

            // Click 'ribbonMain' tool bar

鼠标 Point

            Mouse.Click(uIRibbonMainToolBar, new Point(252, 4));

//单击传输"按钮

            // Click 'Transfer' button

鼠标 Point

            Mouse.Click(uITransferButton, new Point(34, 10));

//在"grdMain"表中键入"g"

            // Type 'g' in 'grdMain' table

键盘 this .RecordedMethod1Params.UIGrdMainTableSendKeys, 修改键

            Keyboard.SendKeys(uIGrdMainTable, this.RecordedMethod1Params.UIGrdMainTableSendKeys, ModifierKeys.None);

//在标题面板"客户端中键入"co {Enter}"

            // Type 'co{Enter}' in 'Header Panel' client

键盘 this .RecordedMethod1Params.UIHeaderPanelClientSendKeys, 修改键

            Keyboard.SendKeys(uIHeaderPanelClient, this.RecordedMethod1Params.UIHeaderPanelClientSendKeys, ModifierKeys.None);

//单击新建"按钮

            // Click 'New' button

鼠标 Point

            Mouse.Click(uINewButton, new Point(12, 15));

//在"ingrpc_fgc_number"文本框中输入"test {Tab}"

            // Type 'test{Tab}' in 'ingrpc_fgc_number' text box

键盘 this .RecordedMethod1Params.UIIngrpc_fgc_numberEditSendKeys, 修改键

            Keyboard.SendKeys(uIIngrpc_fgc_numberEdit, this.RecordedMethod1Params.UIIngrpc_fgc_numberEditSendKeys, ModifierKeys.None);

//在文本框中输入"TEST1"

            // Type 'TEST1' in text box

uIItemEdit.Text = this .RecordedMethod1Params.UIItemEditText;

            uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText;

//在文本框中输入"Control + s"

            // Type 'Control + s' in text box

键盘 this .RecordedMethod1Params.UIItemEditSendKeys, 修改键

            Keyboard.SendKeys(uIItemEdit, this.RecordedMethod1Params.UIItemEditSendKeys, ModifierKeys.Control);

       }

      

       

谢谢,

Vijay Hugar      

推荐答案

维杰,

两件事:

1.您应该查看测试日志,看看CodedUI如何识别第二"控件.如果看到类似找不到名称为xxx的控件...但找到并接受yyy属性的类似控件"之类的消息(措辞不完全相同).但是 要点,如果CodedUI找不到具有指定所有搜索属性的控件,则它将尝试查找与某些搜索属性匹配的另一个控件.

1. You should look into the test log and see how CodedUI identifying the 'second' control. If you see messages like 'Control with name xxx not found...but a similar control with yyy properties found and accepted' (wordings are not exactly same). But the gist, if CodedUI does not find a control with all the search properties specified then it will try to find another control matching a few of the search properties.

如果您发现此类消息,请相应地调整搜索属性.

If you find this kind of a message, then adjust the search properties accordingly.

2.如果两个控件具有相似的搜索属性,则找到一种方法来区分两个控件(它们可能具有不同的直接父级)

2. If two controls are having similar search properties then find a way to distinguish both the controls (they might have a different immediate parent)

您可以使用以下代码查找控件,并查看获得了多少:

You can use the below code to find controls and see how many are you getting:

------------

------------

WinEdit文本框=新的WinEdit(aParentObject); //这里 .UIERP01CompanyWindow.UIGroupCodesGCODWindow

WinEdit textbox = new WinEdit(aParentObject); //Here this.UIERP01CompanyWindow.UIGroupCodesGCODWindow

///在此处添加搜索属性

//Add your search properties here

UITestControlCollection ctrls = textbox.FindMatchingControls();

UITestControlCollection ctrls = textbox.FindMatchingControls();

//在此处观看ctrls集合

//Watch ctrls collection here

------------

------------

如果看到多个控件,它们会尝试添加其他父控件以查找第二个控件(在代码中,两个控件都标识为同一父控件:UITheXtraLayoutControlPane)->仅当两个控件具有不同的层次结构时,才有可能. 如果不使用collection,请选择正确的控件.

If you see multiple controls, they try adding a different parent to find the second control (In the code both controls are identified with same parent: UITheXtraLayoutControlPane) -> This is possible only when both the controls are having different hierarchy. If not use collection and pick the right control.

如果仍然遇到问题,请提及用于搜索控件的代码(UIMap.designer.cs文件)

If you are still facing the issue, mention the code for searching control (UIMap.designer.cs file)


这篇关于编码的UI-工具无法识别从VB.net(Framework 4.0)开发的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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