Using DrawHighlight()
Today we will see how/when to use DrawHighlight() method in CodedUI. The DrawHighlight method is used to highlight a control or focus on control on web page or wpf appication form i.e. User interface.
Sometime control is available on screen and even we can map it using CodedUI TestBuilder but when we try to perform any action on it then it throws exception - control not found or Cant perform click action on hidden control(if it is button control).
So in such situation we can try using the DrawHighlight method as explained below:
In above image sample demo page shown which contains a textbox and a button.
(Here it is taken for just example)
For a textbox and button control we can use Drawhighlight as below :
public void DrawHighlightAndClick()
{
HtmlInputButton btnHi = this.UIDemoWindow.UIDemoDocument.UIHIButton;
btnHi.DrawHighlight();
Mouse.Click(btnHi);
}
public void DrawHighlightAndEnterInput()
{
HtmlEdit txtName = this.UIDemoWindow.UIDemoDocument.UITxtaNameEdit;
txtName.DrawHighlight();
txtName.Text = "test1234";
}
Similarly we can use this method for any control in CodedUI, provided that control is visible on User Interface.
Enjoy Coding !!!
Today we will see how/when to use DrawHighlight() method in CodedUI. The DrawHighlight method is used to highlight a control or focus on control on web page or wpf appication form i.e. User interface.
Sometime control is available on screen and even we can map it using CodedUI TestBuilder but when we try to perform any action on it then it throws exception - control not found or Cant perform click action on hidden control(if it is button control).
So in such situation we can try using the DrawHighlight method as explained below:
In above image sample demo page shown which contains a textbox and a button.
(Here it is taken for just example)
For a textbox and button control we can use Drawhighlight as below :
public void DrawHighlightAndClick()
{
HtmlInputButton btnHi = this.UIDemoWindow.UIDemoDocument.UIHIButton;
btnHi.DrawHighlight();
Mouse.Click(btnHi);
}
public void DrawHighlightAndEnterInput()
{
HtmlEdit txtName = this.UIDemoWindow.UIDemoDocument.UITxtaNameEdit;
txtName.DrawHighlight();
txtName.Text = "test1234";
}
Similarly we can use this method for any control in CodedUI, provided that control is visible on User Interface.
Enjoy Coding !!!

No comments:
Post a Comment