Forum Discussion
dpeterson157
13 years agoContributor
I've attached a small project suite that I created. There are 5 script files named "Person", "Employee", "xPerson", "xEmployee" and "xManager". Each scritp contains a simple test function that creates an object and writes the contents of its "toString" function to the log. The inheritance hierarchy is as such:
Person
Employee - Employee's toString function calls Person's toString function.
Manager - Manager's toString function calls Employee's toString function.
I've also included the log files from each test run. The first three logs are from executing the test functions of xPerson, xEmployee and xManager, respectively. All worked as intended.
I then defined script objects "Person" and "Employee". The contents of these scripts are identical to the contents of "xPerson" and "xEmployee" except that I changed the strings printed to the log to make them easier to identify.
I then ran the test function from "Person", no problems, none expected.
I then ran the test function from "Employee", but in this case the first line in the script was "//USEUNIT Person". This generated the runtime error "Object doesn't suppport this property or method" indicated in the log.
In script "Employee", I changed the first line to "//USEUNIT xPerson" and executed the test function again. This time the execution was correct.
My installation of TestComplete includes no plug-ins or extensions that didn't come with the original installation file.
So, to make JavaScript prototypal inheritance work in TestComplete, give the script modules slightly different names than the object being defined.
Dave
Person
Employee - Employee's toString function calls Person's toString function.
Manager - Manager's toString function calls Employee's toString function.
I've also included the log files from each test run. The first three logs are from executing the test functions of xPerson, xEmployee and xManager, respectively. All worked as intended.
I then defined script objects "Person" and "Employee". The contents of these scripts are identical to the contents of "xPerson" and "xEmployee" except that I changed the strings printed to the log to make them easier to identify.
I then ran the test function from "Person", no problems, none expected.
I then ran the test function from "Employee", but in this case the first line in the script was "//USEUNIT Person". This generated the runtime error "Object doesn't suppport this property or method" indicated in the log.
In script "Employee", I changed the first line to "//USEUNIT xPerson" and executed the test function again. This time the execution was correct.
My installation of TestComplete includes no plug-ins or extensions that didn't come with the original installation file.
So, to make JavaScript prototypal inheritance work in TestComplete, give the script modules slightly different names than the object being defined.
Dave
Related Content
- 4 years ago
- 12 years ago
- 6 years ago
- 3 years ago
Recent Discussions
- 5 hours ago