PowerBuilder code samples (in Java)

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()throws GeneralLeanFtException {
	//Create a description for main AUT window.
	//Set the correct properties in order to identify the window uniquely
	Window wndMainWindow = Desktop.describe(Window.class, new WindowDescription.Builder()
		.nativeClass("FNWND3126")
		.objectName("wnd_main")
		.windowTitleRegExp("Main window12.0").build());
	//Create a description for the second window from the hierarchy.
	//Set the correct properties in order to identify the window uniquely
	Window wTabRunWindow = wndMainWindow.describe(Window.class, new WindowDescription.Builder()
		.nativeClass("FNWND3126")
		.objectName("w_tab_run")
		.windowTitleRegExp("Example of Tab").build());
	//Create a description for the TabControl.
	//Set the correct properties in order to identify the TabControl uniquely
	TabControl tab1TabControl = wTabRunWindow.describe(TabControl.class, new TabControlDescription.Builder()
		.nativeClass("PBTabControl32_100")
		.objectName("tab_1").build());

	//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.getSelectedTab().getText());

}				

Back to top

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
publicvoid TestTable()throws GeneralLeanFtException {
	//Create a description for main AUT window.
       //Set the correct properties in order to identify the window uniquely
	Window wndMainWindow = Desktop.describe(Window.class, new WindowDescription.Builder()
		.nativeClass("FNWND3126")
		.objectName("wnd_main")
		.windowTitleRegExp("Main window12.0").build());
	//Create a description for the second window from the hierarchy.
       //Set the correct properties in order to identify the window uniquely
	Window wGridWindow = wndMainWindow.describe(Window.class, new WindowDescription.Builder()
		.nativeClass("FNWND3126")
		.objectName("w_grid")
		.windowTitleRegExp("Field Grid ver 4.1").build());
	//Create a description for the Table.
       //Set the correct properties in order to identify the Table uniquely
	Table dw1Table = wGridWindow.describe(Table.class, new TableDescription.Builder()
		.nativeClass("pbdw126")
		.objectName("dw_1").build());

	//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.getRows().get(0).getCells().get(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
	String result = dw1Table.getTableProperty("DataWindow.Color");

	//Verify that the color has the correct value.
	Verify.areEqual("16711611", result);
} 

Back to top

See also: