cancel
Showing results for 
Search instead for 
Did you mean: 

Script says the java class function as "Not a function". Pleas help how to fix this.

Contributor

Script says the java class function as "Not a function". Pleas help how to fix this.

Hi,

 

JavaClasses.mongoDB.MongoDBInitialize.getShippedOrderCounts(); 

 

mongoDB is a package ,

 

MongoDBInitialize is a class and 

 

getShippedOrderCounts(); is  a static method in the class.

 

 

But on execution it says, getShippedOrderCounts() is not a function.

 

I have sett java, java -bridge, jar and class included in place.

 

8 REPLIES 8
Community Hero

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

That may be a function in the class, but it might not be exposed as such in TestComplete.  You SHOULD be able to get code completion/intellisense in TestComplete once you try the code in place.  What does it show up as in TC?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Highlighted
Contributor

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

There is nothing after the class is shown when used
Javaclasse.Packages.class.__.
One thing to mention .. documentation says in syntax to use subclass after the class. Is that mandatory?
Contributor

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

I am not able to get the static methods of the Java class in code completion.

 

Also if I type the methd name after the class name , on runtime its says the function name as not-a function.

 

e.g. I tried mongodb. MongoDBInitialize.getShippedOrders().......... then it says getShippedOrders() as not a function.

 

I am able to get package mongodb and MongoDBInitialize class after JavaClasses but not the getShippedOrders()  method after that.

 

Please advise.

Contributor

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

Is there anyone who can help. 

 

I tried a fresh TestComplete project and configured java bridge at tool level and also listed the jav classes and the java class path in the form of a jar file.

 

Still I am getting the same issue.

Errro in the log-

 

"ErrorTypeError: JavaClasses.mongoDB.MongoDBInitialize.getShippedOrderCounts is not a function
at connectToMongoDB (<aq:Unit1>:7:64) 12:45:28 Normal 0.00"

 

 

I can't see my static methid listed in the code completion so as a result it says the method in the class as not-a function on runtime.

Community Hero

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

So... this Java class... is this one you wrote yourself?  something you got somewhere else?  Because "getShippedOrderCounts" seems to be AWFULLY specific for a generic MongoDB JAR library.  You might need to do some work within your JAR to expose the method.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

Hi @tristaanogre 

 

I have written the class by myself which basically has two static methods in it. So I followed the documentation in the smartbear portal, I followed everything there, there was nothing specific about exposing the methids in the class.

Community Hero

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

The documentation available from TestComplete simply talks about how to consume JAR classes/files.  If you need specific help in creating your own unique JAR, you might need to contact SmartBear support directly.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Contributor

Re: Script says the java class function as "Not a function". Pleas help how to fix this.

@tristaanogre .. OK. Thank You! 

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors