如何使用编码ui从网页中获取文本


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 Store应用程序,请使用Windows Store节点下的Windows Store应用程序的编码UI测试项目模板。'这段代码中缺少什么吗?如果您能提供配置缺失组件的链接,将不胜感激

您要查找的属性是"InnerText"。例如,在像

这样的超链接上
HtmlHyperlink target = new HtmlHyperlink();
target.SearchProperties[<search property>] = <value>;
string myText = target.InnerText;

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

相关内容

  • 没有找到相关文章

最新更新