PowerBuilder code samples (JavaScript SDK)

Select a Tab from a TabControl

This example selects a tab on an application and verifies that the correct tab was selected.
var LFT = require("leanft");
var SDK = LFT.SDK;
var expect = require("leanft/expect");
var whenDone = LFT.whenDone;
var Desktop = LFT.Desktop;
var PowerBuilder = LFT.PowerBuilder;
var assert = require('assert');

 jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;
 
describe("My Site",function(){
    beforeEach(function(done){
        SDK.init();      
        whenDone(done);
    });
 
    it("Test TabControl",function(done){      
        //Create a description for main AUT window.
        //Set the correct properties in order to identify the window uniquely
        var wndMainWindow = Desktop.$(PowerBuilder.Window({
		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.$(PowerBuilder.Window({
		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.$(PowerBuilder.TabControl({
		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.
        tab1TabControl.selectedTab().then(function(tab){
		tab.text().then(function(result){
		assert.deepEqual("Tab 3 ", result);
               });
        });

        whenDone(done);
    });
			
    afterEach(function(done){       
        SDK.cleanup();
        whenDone(done);
    });
});					

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.
var LFT = require("leanft");
var SDK = LFT.SDK;
var expect = require("leanft/expect");
var whenDone = LFT.whenDone;
var Desktop = LFT.Desktop;
var PowerBuilder = LFT.PowerBuilder;
var assert = require('assert');

 jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;

describe("My Site",function(){
    beforeEach(function(done){
        SDK.init();      
        whenDone(done);
    });

    it("Test Table",function(done){   
        //Create a description for main AUT window.
        //Set the correct properties in order to identify the window uniquely
        var wndMainWindow = Desktop.$(PowerBuilder.Window({
		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.$(PowerBuilder.Window({
		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.$(PowerBuilder.Table({
		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.cells(0, 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
        dw1Table.getTableProperty("DataWindow.Color").then(function(result){			
            //Verify that the color has the correct value.
            assert.deepEqual("16711611", result); 
        });  
	   
        whenDone(done);
    });
    afterEach(function(done){       
        SDK.cleanup();
        whenDone(done);
    });	
});					

Back to top

See also: