0
I am new for coded ui and I have got stuck for processing message display on webpage. As we used to get text from web page in selenium using method getText(), is such kind of possibility are available in coded ui.?

I would appreciate your help!!!!

Thanks,
Dani

更新 - 2014 年 5 月 14 日

脚本代码:

 public void FPInternetExplorer()
        {
            #region Variable Declarations
            HtmlEdit uIUserNameEdit = this.UIFundingPilotPortalWiWindow.UIFundingPilotPortalDocument.UIUserNameEdit;
            HtmlEdit uIPasswordEdit = this.UIFundingPilotPortalWiWindow.UIFundingPilotPortalDocument.UIPasswordEdit;
            HtmlInputButton uILoginButton = this.UIFundingPilotPortalWiWindow.UIFundingPilotPortalDocument.UILoginButton;
            HtmlEdit uISecurityQuestionAnswEdit = this.UIFundingPilotPortalWiWindow.UIFundingPilotPortalDocument.UISecurityQuestionAnswEdit;
            HtmlInputButton uIValidateButton = this.UIFundingPilotPortalWiWindow.UIFundingPilotPortalDocument.UIValidateButton;
            #endregion

            this.UIInternetExplorerEnhaWindow6.LaunchUrl(new System.Uri(this.FPInternetExplorerParams.UIInternetExplorerEnhaWindow6Url));

            // Type 'test@test.test' in 'User Name' text box
            uIUserNameEdit.Text = this.FPInternetExplorerParams.UIUserNameEditText;

            // Type '{Tab}' in 'User Name' text box
            Keyboard.SendKeys(uIUserNameEdit, this.FPInternetExplorerParams.UIUserNameEditSendKeys, ModifierKeys.None);

            // Type '********' in 'Password' text box
            uIPasswordEdit.Password = this.FPInternetExplorerParams.UIPasswordEditPassword;

            // Click 'Login' button
            Mouse.Click(uILoginButton, new Point(62, 19));

    //Code to get the text from div tag. This is the code I have added  
            HtmlDiv testLabel = new HtmlDiv();
            testLabel.SearchProperties[HtmlDiv.PropertyNames.Id] = "SecurityQuestion_AnswerText";
            string myText = testLabel.InnerText;
            Console.Write("myText " + myText);

            // Type 'Computer' in 'SecurityQuestion.AnswerText' text box
            uISecurityQuestionAnswEdit.Text = this.FPInternetExplorerParams.UISecurityQuestionAnswEditText;

            // Type '{Tab}' in 'SecurityQuestion.AnswerText' text box
            Keyboard.SendKeys(uISecurityQuestionAnswEdit, this.FPInternetExplorerParams.UISecurityQuestionAnswEditSendKeys, ModifierKeys.None);

            // Click 'Validate' button
            Mouse.Click(uIValidateButton, new Point(81, 25));
        }

// 使用编码 UI 运行此代码时,系统给出异常:消息 - '要测试 Windows 应用商店应用,请使用 Windows 应用商店节点下的 Windows 应用商店应用的编码 UI 测试项目模板。' 此代码中是否缺少某些内容?如果您能提供链接以配置缺少的组件,将不胜感激

4

1 回答 1

0

您要查找的属性是“InnerText”。因此,例如,在像这样的超链接上:

HtmlHyperlink target = new HtmlHyperlink();
target.SearchProperties[<search property>] = <value>;
string myText = target.InnerText;

您可以通过选择页面的外部容器并获取它的 InnerText 来推断它只是读取页面上的所有文本,然后通过字符串解析您想要的内容,但是如果您发现它会简单得多在最专注的对象上工作。

于 2014-05-13T15:08:11.627 回答