在Playback中设置UIElementText时,编码的UI测试未运行 [英] Coded UI test is not running while setting the UIElementText in the Playback

查看:52
本文介绍了在Playback中设置UIElementText时,编码的UI测试未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS2015 Coded UI Test构建器记录了编码的UI测试。根据我的记录,为我的测试方法创建了以下函数,

I have recorded the coded UI test using the VS2015 Coded UI Test builder. based on my recording the following function is created for my test method,

        public void RecordedMethod1()
        {
            #region Variable Declarations
            WpfText uIItemText = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom.UIItemText;
            WpfEdit uIItemEdit = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom.UIItemEdit;
            WpfText uIItemText1 = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom1.UIItemText;
            #endregion

            // Double-Click label
            Mouse.DoubleClick(uIItemText, new Point(73, 3));

            //// Failed in the following line and the test is not running after that.
            // Type 'aaa' in text box
            uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText;

            // Double-Click label
            Mouse.DoubleClick(uIItemText1, new Point(79, 10));

            // Type 'bbb' in text box
            uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText1;

            // Type '{Enter}' in text box
            Keyboard.SendKeys(uIItemEdit, this.RecordedMethod1Params.UIItemEditSendKeys, ModifierKeys.None);
        }

到达该行后,将记录的值设置为< strong> uiEditItem.Text  ,测试用例未进一步运行测试用例中的失败。

After reaching the line to set the recorded value to the uiEditItem.Text the test case is not running further cased the failure in the test case.

我已经搜索了解决方案,并找到一个说,你需要用Kebord.SendKeys重写测试用例,而不是直接设置值到EditItem的文字  属性。

I have googled for the solution and have found a one that says, you need to rewrite the test cases with the Kebord.SendKeys instead of directly setting the value to the Text property of the EditItem.

通过这种方式,我在代码行中更改了代码,如下所示。

By this way I have made my code changes at the line as follows and its working.

// Type 'aaa' in text box
//uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText;

// Replaced the above line with the SenKeys 
Keyboard.SendKeys(this.RecordedMethod1Params.UIItemEditText);

这是唯一的这个问题的解决方案(Manullay使用SendKeys方法重写测试方法,而不是直接为uiEditItem.Text属性赋值)?如果没有,请为此提供可行的解决方案。

Is that the only solution for this problem (Manullay rewrite the test methods by using the SendKeys method instead of directly assigning a value to the uiEditItem.Text property) ? If not, please provide the feasible solution for this.

推荐答案

您好Adhik7,

Hi Adhik7,

我通常使用  Keyboard.SendKeys()方法。

I often use the Keyboard.SendKeys() method.

myInputEdit.Text = "";

Keyboard.SendKeys(myInputEdit, "Some Text");

如果你真的想用你以前的方式,也许你可以使用  myInputEdit.Text
=""首先,然后再次使用
uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText。

If you really want to use your previous way, maybe you could use the myInputEdit.Text = "" firstly, and then use the uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText again.

此外,请在输入值之前添加延迟:

In addition, please also add a delay before you input the value:

https://docs.microsoft.com/en-us/visualstudio/test/making-coded-ui -tests-wait-for-specific-events-playback-playback?view = vs-2017

https://docs.microsoft.com/en-us/visualstudio/test/making-coded-ui-tests-wait-for-specific-events-during-playback?view=vs-2017

再次检查结果。如果不行,请随时告诉我。还请分享我详细的错误信息。

Check the result again. If not work, feel free to let me know. Please also share me the detailed error messages.

最好的问候,

杰克


这篇关于在Playback中设置UIElementText时,编码的UI测试未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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