Hi Friends.Today we will see how to verify font properties of control if it is visible on page.
In CodedUI we have UITestingUtilities dll that helps us a lot in finding control or verifying control existance by providing many extended methods.This utility provides methods to check color and font properties.
In below sample code we have shown how to check font of a control.
This method works fine in web application automation.
//pre-requisite : UITestingUtilities.dll, Microsoft.CSharp , System.Core
Pre-conditions: Along with UITestingUtilities.dll we need to add Microsoft.CSharp , System.Core reference to avoid any reference not found errors.
To download UITestingUtilities please check this link :UITestingUtilities.dll
Enjoy Coding !!!
In CodedUI we have UITestingUtilities dll that helps us a lot in finding control or verifying control existance by providing many extended methods.This utility provides methods to check color and font properties.
In below sample code we have shown how to check font of a control.
This method works fine in web application automation.
//pre-requisite : UITestingUtilities.dll, Microsoft.CSharp , System.Core
public void VerifyContolFont()
{
HtmlInputButton btnHi = UIHttplocalhostDemDocument.UIHIButton;
IHTMLCurrentStyle btnStyle = btnHi.GetCurrentStyle();
//verify font is regular or bold . for regular=400 and for bold=700
if (btnStyle.fontWeight.ToString() != "400")
{
throw new AssertInconclusiveException("Font is not regular");
}
//Verify font family
if (btnStyle.fontFamily.ToString() != "arial")
{
throw new AssertInconclusiveException("Font family is not arial");
}
}
GetCurrentStyle() : This methods gets all the style properties of the control.
To download UITestingUtilities please check this link :UITestingUtilities.dll
Enjoy Coding !!!