This is a migrated thread and some comments may be shown as answers.

How do we validate an enabling and disabling function

5 Answers 191 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
QA
Top achievements
Rank 1
QA asked on 05 Apr 2011, 05:13 PM
Hello,

I have run into some simple(hopefully) issues. I am trying to test these scenarios.... and cannot figure out how to to add a verification that checked if something is enabled or disabled based on a checkbox being checked or not.

Test Scenario 1:
Unchecking a checkbox should disable three things, 1. Text Box, 2. Title background color changes field and 3. Title foreground color changes.

Test Scenario 2:
Checking a checkbox should enable three things, 1. Text Box, 2. Title background color changes field and 3. Title foreground color changes.

Test Scenario 3: Is it possible for Web UI to distinguish between two colors? I need to make a selection for a background color and ensure that the change reflects in the background on the App. Possible?

Let me know if any of the above can be done.
QA

5 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 06 Apr 2011, 10:10 PM
Hello QA,

Yes, your desired verifications are possible. A coded step is required to test if a control or element is disabled:

HtmlInputButton btn = Find.ById<HtmlInputButton>("Button1"); 
  
Assert.IsTrue(btn.BaseElement.OuterMarkup.Contains("disabled"));

To create a background color verification, hover anywhere in the background with hover over highlighting enabled. Click the blue nub and choose "Build Verification." Select "Style" as a verification. Its second drop-down can be changed to ColorAndBackground and with the third drop-down you can distinguish between Color and BackgroundColor.

All the best,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
QA
Top achievements
Rank 1
answered on 07 Apr 2011, 02:33 PM
Thanks for the reply:

I do not see Style as an option after hovering over the background of that title window. I see Property, Visibility, Location and ToolTip.

The Target element is <Textboxview basetype='Frameworkelement' Uid=15299237'>

Hope that helps to understand where I am trying to verify color.

QA
0
Anthony
Telerik team
answered on 07 Apr 2011, 06:10 PM
Hello QA,

I am sorry for the confusion. What I showed you was for the HTML world. You're dealing with Silverlight instead and the approach is completely different.

We've had requests for this before but don't yet have a good mechanism in place to handle color testing in Silverlight. It can be done in code. This example is for a foreground color but can be easily be changed to background color.

Let's assume you have XAML like this:

<TextBox Text="{Binding Name, Mode=TwoWay, ValidatesOnExceptions=True}"
VerticalAlignment="Center" Margin="2 0 2 0" Foreground="#284869"
FontWeight="Bold" Padding="0" MinWidth="60" />

The Foreground property is what we're after. In code we have to fetch the Foreground property and then test the A, R, G, B components it contains like this:

Brush textblockBrush = (Brush)Pages.TelerikTreeViewFor.SilverlightApp.InstallerTextblock.GetProperty(new AutomationProperty("Foreground", typeof(Brush)));
if (textblockBrush is SolidColorBrush)
{
    Color actualColor = ((SolidColorBrush)textblockBrush).Color;
    Assert.AreEqual<Byte>(0xff, actualColor.A, "Error: alpha component does not match expected.");
    Assert.AreEqual<Byte>(0x28, actualColor.R, "Error: red component does not match expected.");
    Assert.AreEqual<Byte>(0x48, actualColor.G, "Error: green component does not match expected.");
    Assert.AreEqual<Byte>(0x69, actualColor.B, "Error: blu component does not match expected.");
}
else
{
    // If it's not a SolidColorBrush what is it? How do we handle it?
    throw new ApplicationException("The brush is not a SolidColorBrush");
}

Note how the numbers being compared are pulled right from the Foreground property setting contained in the XAML code.

I have attached a sample test demonstrating this in action.

All the best,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
QA
Top achievements
Rank 1
answered on 07 Apr 2011, 08:13 PM
Thanks Anthony! That helps. I cannot try it yet because I have a pending open ticket which needs to be resolved/or a workaround found before I can actually automate the background foreground verification.

At the same time, Could you may be give an example of code for the enable disable piece that was in the original post. I think your example was in HTML.

Thanks!
0
Anthony
Telerik team
answered on 07 Apr 2011, 10:21 PM
Hello QA,

We have a way to test if a Silverlight element is disabled through the UI, so code should not be necessary. We are aware that the blue nub will not appear when "hover over highlighting" is enabled and your mouse is over a disabled Silverlight element. We have a bug logged for this. But here's a simple work-around to build the desired verification:

1. Enable hover over highlighting, mouse over an element near the disabled element, and click the blue nub.
2. Choose Locate in DOM.
3. Find the desired disabled element in the DOM.
4. Right click on it and choose Show Element Menu.
5. Build Verification.
6. Choose Property, IsEnabled, Equal, False

See the attached screen shot for an example of the verification. Of course you can right click the step once done and choose Customize in Code to make further changes.

Regards,
Anthony
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
QA
Top achievements
Rank 1
Answers by
Anthony
Telerik team
QA
Top achievements
Rank 1
Share this question
or