Verifying Silverlight tool-tips sometimes can be tricky. First we must understand that tool-tips are attached to elements and Test Studio has the ability to verify what the tool-tip is that is attached to a specific element. We don't try to get the tool-tip element itself and verify the tool-tip contents, because a tool-tip is just a property of the Silverlight UI element for which the tool-tip is intended to be displayed.
One other small hurdle is that in order to verify a tool-tip, it must first appear in the Silverlight Visual Tree, which is Microsoft's internal representation of the Silverlight application UI. The first trick is to Invoke a Mouse Hover event. By hovering the mouse over the element, it causes the tool-tip to appear in the UI, which also adds it to the Visual Tree. Once it appears you can try to add a tool-tip verification of your UI element.
In some cases, just highlighting the UI element in the recorder and adding a tool-tip verification doesn't work as expected.
The problem is that the tool-tip is being applied to the parent RatingItem element and not the child Grid or TextBlock elements. To further complicate things, we can't simply find the RatingItem element in the DOM Explorer and try to use the Sentence Verification Builder to create a tool-tip verification. You can find the RatingItem element in DOM Explorer, but Test Studio won't be able to build a tool-tip verification for it.
Instead we have to resort to code to perform our tool-tip verification. First add the RatingItem element to the Project Elements.
1. Highlight the element. 2. Click Locate in DOM. 3. Highlight the parent RatingItem element and ensure it matches on the page.
4. Right click the element in the DOM and select Add to Project Elements.
Now we have an element reference we can use in a coded step. Next add a coded step as follows:
FrameworkElement elem = Pages.SilverlightToolkitSamples.SilverlightApp.AmusedRatingitem; string actualTip = elem.ToolTipText; Log.WriteLine(actualTip); Assert.AreEqual<string>("Amused", actualTip);
Dim elem As FrameworkElement = Pages.SilverlightToolkitSamples.SilverlightApp.AmusedRatingitem Dim actualTip As String = elem.ToolTipText Log.WriteLine(actualTip) Assert.AreEqual(Of String)("Amused", actualTip)