I am writing a test to work on a RichTextBox (Silverlight) which has several hundred Text Box elements. Tasks include both typing in as well as content verification. I have run into a couple of issues - hoping someone can help.
a) I am trying to type in a string at a specific location (for example, in between two text elements). I have written a coded step (clicks on one of the text boxes) that gets the cursor to the correct position. I then have a Type Text statement (tried both recorded as well as a coded step) that types in a string. I am expecting the string to be typed in at the cursor position - however, the text shows up somewhere above the cursor (on a different line).
Is there anything I can do to get the test to type in at the desired location?
Here is the relevant code:
// LeftClick on Textblock10
RashOnTheTextblock2.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 73, 43, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
// Type 'upperarm' into RichTextEditorClinicalNoteRichtextbox5
, 10, 100,
b) Is there a fast way to collect all the text boxes in the RichTextBox into an IList or another collection element and/or to find all TextBlocks matching a certain text or another property?
Here is my current code:
// Get all lines in the current progress note.
// NOTE: The array will contain lines that are empty or are not visible to the eye in the Progress Note ("Spelling Suggestions", "Name:", "Url" - these are the last 3 lines in the array).
rtbCurrentPNLines = rtbNote.Find.AllByType<TextBlock>();
// Get all instances of multiply occurring text (that this test will use)
// 'PROBLEM '
PROBLEMTextBlocks = PNContents.Where<TextBlock>((a_) => (a_).Text.Equals(
The problem with both the above is that it takes several seconds to execute each of the above - the first one takes 20+ seconds for about 600+ Text Blocks. Further, I have to do this multiple times as the contents are changing during the test and verifications have to be done after those changes. So, as you can imagine, running time of the test is increasing dramatically as the test is further developed.
NOTE: None of the text boxes have x:Names or Automation IDs and there are several duplicates - so simple recorded steps for text block verifications does not work. Content of the note is dynamically generated (they are not in a xaml file). GIven current release schedules, it is highly unlikely that devs will have time to modify the code to assign x:Names or Automation IDs for us to reference elements directly.
Any help for the above questions would be greatly appreciated. By the way, I need solutions that will work with the version of TS that I am using (see my signature below). We do plan to upgrade to a more recent version- but that won't be for a couple of months (at least). Again, the app is a Silverlight application.
Test Studio 2012.2.1420.0