Forum Discussion
Philip_Baird
12 years agoCommunity Hero
Hi Sergi, unfortunately prototype augmentation only applies to the Script Unit in which it is declared.
From what I have observed, each Script Unit runs in it's own "sandbox" which puts in place this restriction.
I have had success in the pass using Factory functions in relation to augmented prototypes, e.g.
// Factory function
function AiArray(){
if( arguments.length === 1 ){
return new Array().concat( arguments[ 0 ] );
}
return new Array()
}
// Augment Array
Array.prototype.clear = function() {
if( ! this.isEmpty() ) {
this.splice( 0, this.length );
}
}
However, since you are implementing an inheritance function this may not be efficient.
As an aside, I use Base.js for inheritance, so far this has worked well for me in Test Complete.
Regards,
Phil Baird