PowerBuilder code samples (.NET SDK)
Select a Tab from a TabControl
This example selects a tab on an application and verifies that the correct tab was selected.
[Test] public void TestTabControl() { //Create a description for main AUT window. //Set the correct properties in order to identify the window uniquely var wndMainWindow = Desktop.Describe<IWindow>(new WindowDescription { NativeClass = @"FNWND3126", ObjectName = @"wnd_main", WindowTitleRegExp = @"Main window12.0" }); //Create a description for the second window from the hierarchy. //Set the correct properties in order to identify the window uniquely var wTabRunWindow = wndMainWindow.Describe<IWindow>(new WindowDescription { NativeClass = @"FNWND3126", ObjectName = @"w_tab_run", WindowTitleRegExp = @"Example of Tab" }); //Create a description for the TabControl. //Set the correct properties in order to identify the TabControl uniquely var tab1TabControl = wTabRunWindow.Describe<ITabControl>(new TabControlDescription { NativeClass = @"PBTabControl32_100", ObjectName = @"tab_1" }); //Use the Select method and pass the name of the tab, exactly as it is in the AUT. tab1TabControl.Select("Tab 3 "); //Verify whether the selection was made by checking the SelectedTab property. Verify.AreEqual("Tab 3 ", tab1TabControl.SelectedTab.Text); }
Set an item in a combo box
This example sets an item in a combo box nested in a Table control, and verifies the Color property of the table.
[Test] public void TestTable() { //Create a description for main AUT window. //Set the correct properties in order to identify the window uniquely var wndMainWindow = Desktop.Describe<IWindow>(new WindowDescription { NativeClass = @"FNWND3126", ObjectName = @"wnd_main", WindowTitleRegExp = @"Main window12.0" }); //Create a description for the second window from the hierarchy. //Set the correct properties in order to identify the window uniquely var wGridWindow = wndMainWindow.Describe<IWindow>(new WindowDescription { NativeClass = @"FNWND3126", ObjectName = @"w_grid", WindowTitleRegExp = @"Field Grid ver 4.1" }); //Create a description for the Table. //Set the correct properties in order to identify the Table uniquely var dw1Table = wGridWindow.Describe<ITable>(new TableDescription { NativeClass = @"pbdw126", ObjectName = @"dw_1" }); //In the table, select the row and then the cell that contains the combo box. //Use SetValue method to set the item in a combo box dw1Table.Rows[0].Cells[15].SetValue("Bond, Charles F."); //Use the GetTableProperty method to retrieve power builder properties //Pass the property that you want to retrieve. //For a full list of what you can retrieve, see: //http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc37783.1252/html/dwref/CCJBHCCF.htm var result = dw1Table.GetTableProperty("DataWindow.Color"); //Verify that the color has the correct value. Verify.AreEqual("16711611", result); }