The following code sample reads the selected colors (red, green and blue) from the dialog, sets red=64, green=128 and blue=192 and clicks the OK button.
Code: click into code to enlarge
Form form = Application.FindFormTitle("Color");
if (form == null)
return 1;
Element red = form.Element.FindChild(Role.Text, "Red:");
Element green = form.Element.FindChild(Role.Text, "Green:");
Element blue = form.Element.FindChild(Role.Text, "Blue:");
if( red == null || green == null || blue == null )
{
Console.WriteLine("ERROR: red, green or blue edit box not found");
return 1;
}
Console.WriteLine("Color Red={0} Green={1} Blue={2}", red.Value, green.Value, blue.Value);
red.Value = "64";
green.Value = "128";
blue.Value = "192";
Element okButton = form.Element.FindChild(Role.PushButton, "OK");
if (okButton != null)
Mouse.ClickElement(okButton);
return 0;
Gabor
Ranorex Team |