Forum Discussion

birno's avatar
12 years ago

Access object methods from a custom class

Hi,



I'm writing tests to a WPF application, using JScript language and I create a custom class which hold some custom method for datagrid handling.

Looks like this:




function MyGrid(dataGrid){

    this.dataGrid = dataGrid; // dataGrid is a System.Windows.Controls.DataGrid object



    // add some custom function here

}



Then I using this on an other unit:



var grid = new MyGrid(<path to the dataGrid object>);



Works fine, the problem comes when I wanna use a method of the original System.Windows.Controls.DataGrid object for example ClickCell.



grid.ClickCell(1,1);



I get an "Object doesn't support this property or method" error, it's okay, because my custom object doesn't have a method like that.

I know I can use use that method in this way: grid.dataGrid.ClickCell(1,1);

But is it possibble to tell testcomplete that MyGrid class is a System.Windows.Controls.DataGrid wrapper class and access that object methods through the "this.dataGrid" variables automatically?

Like inheritance in other languages.



Or the only solution to write wrapper methods in the MyGrid class to every native function I wanna use?

Like this:



this.ClickCell = function(rowNum, colNum) { this.dataGrid.ClickCell(rowNum, colNum) };



Thanks.