Golem.White, Technical Details - ProtoTest/ProtoTest.Golem GitHub Wiki
=====
Screen Objects are created by the automation engineer to combine items with similar functionality into groups that can easily be accessed by test objects. Using Screen Objects allows you to locate and manipulate elements such as Textboxes, ComboBoxes, and other user interface properties. Objects in the application being tested can be located using the Windows Development Kit's Inpsect.exe.
Once an object in the application being tested is found and identified it can be added to the screen object class. Golem.White.Elements must have a TestStack.White.UIItems.Finders.SearchCriteria object passed into when the object is instantiated. Additionally, White.Elements can have a parent object passed in as well as a string that will serve as the name of the object.
private WhitePanel CrossSectionPanel = new WhitePanel(SearchCriteria.ByAutomationId("CrossSectionViewPane"));
public WhiteCheckBox Nominal = new WhiteCheckBox(SearchCriteria.ByAutomationId("displayOptions1"), CrossSectionPanel);
Below you will notice an complete example Screen Object for an Open File dialog box.
using Gallio.Framework;
using ProtoTest.Golem.White;
using System;
using System.Collections.Generic;
using System.Threading;
using ProtoTest.Golem.White.Elements;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
using TestStack.White.UIItems.ListBoxItems;
using TestStack.White.UIItems.WindowItems;
namespace Golem.White.ScreenObjects.Example
{
public class OpenFile_Dialog : BaseScreenObject
{
private static WhiteWindow OpenFileWindow = new WhiteWindow(SearchCriteria.ByText("Open"), WhiteTestBase.window, "OpenModal");
private WhiteButton OpenButton = new WhiteButton(SearchCriteria.ByText("Open"), OpenFileWindow);
private WhiteButton CancelButton = new WhiteButton(SearchCriteria.ByText("Cancel"), OpenFileWindow);
private WhiteComboBox FileName = new WhiteComboBox(SearchCriteria.ByText("File name:"), OpenFileWindow);
public void OpenaFile(String filepathtoOpen)
{
FileName.EditableText = filepathtoOpen;
OpenButton.Click();
List<Window> activeWindows = WhiteTestBase.app.GetWindows();
while (activeWindows.Count > 1)
{
Thread.Sleep(250);
}
}
}
}