HOW TO CLICK IN BUTTONS WITHOUT RECORDING ACTIONS

Author: Alfonso Alarcón

In Coded UI Test solutions of visual Studio (Enterprise, Ultimate or Premium versions) is recommendable to optimize efforts avoiding recording actions when a large numbers of elements must be recorded. See the general strategy from https://automatedtestingtools.wordpress.com/2016/04/19/strategy-to-get-automated-testing-without-recording-actions

In the next class is shown a method to click in buttons such as ok, cancel, confirm, exit….

public static WinButton WinButton;

private static Dictionary<string, WinButton> objDict = UiTestWinButtonDict.UiTestWinButton();

public static void DoubleClickInButton(string tableKey)
{
	WinButton winButton = objDict[tableKey];
	if (winButton.WaitForControlReady(2000))
	{
		Mouse.DoubleClick(winButton);
	}
	else
	{
		Assert.Fail("The button is not ready or does not exist.");
	}
}

As it is shown in the previous code the UI Control of the grid parent is stored in a dictionary. Please see the next post for more information of how to store UI Controls in dictionaries: https://automatedtestingtools.wordpress.com/2016/03/28/how-to-create-dictionaries-to-add-ui-controls

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s