Share this page

# PowerBuilder code samples (.NET SDK)

In this topic:

## 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);

    }

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]
    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);
    }

Back to top

https://admhelp.microfocus.com Functional Testing for Developers 8942
Tips to improve your search results... OpenText™ Functional Testing for Developers Help Center OpenText™ Functional Testing for Developers Help 25.2 All View Local Help Center View Online Help Center Version: