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
updated - 5/14/2014
script code:
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 '[email protected]' 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));
}
// When run this code using coded UI, system gives exception: Message - 'To test Windows Store apps, use the Coded UI Test project template for Windows Store apps under the Windows Store node.' Is something missing in this code? Would appreciate if you could provide link to configure missing component
The property you're looking for is "InnerText". So, for example, on a hyperlink like:
HtmlHyperlink target = new HtmlHyperlink();
target.SearchProperties[<search property>] = <value>;
string myText = target.InnerText;
You can extrapolate this to just read all of the text on the page by selecting the outer container of the page and getting the InnerText of it, then parse through the string for what you want, but I've found it a lot simpler if you work in the most focused object.