How to invoke java method
How to invoke java method
Hi,
I’m trying to automate some Java Applet functionality. I have an object within the applet, for which developers created couple APIs. How can I call those APIs against the object?
Thank you in advance
I’m trying to automate some Java Applet functionality. I have an object within the applet, for which developers created couple APIs. How can I call those APIs against the object?
Thank you in advance
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
You can call the API using following code snippet:
Please make sure, that you are working with our latest Java plug in to make sure that everything works as expected from our blog:
http://www.ranorex.com/blog/automation- ... plications
WARNING: Since Ranorex 3.1 the Java plugin is already delivered with the Ranorex setup. See the User Guide on how to instrument your Java application for automation.
Regards,
Tobias
Support Team
var result = <yourJavaElement>.Element.InvokeAction (“invokemethod”, <methodname>, <parameters>,...);You can use following data types as parameters:
- long
- int
- string
- bool
- null
Please make sure, that you are working with our latest Java plug in to make sure that everything works as expected from our blog:
http://www.ranorex.com/blog/automation- ... plications
WARNING: Since Ranorex 3.1 the Java plugin is already delivered with the Ranorex setup. See the User Guide on how to instrument your Java application for automation.
Regards,
Tobias
Support Team
Re: How to invoke java method
Thank you. I will try it
Dima
Dima
Re: How to invoke java method
Here is the problem. I have a method to invoke, which was provided by developers as public. However, method's input parameter is object type of java.awt.Rectangle. Based on your explanation above, I can only use primitive variables to invoke the methods. So what is the possible solution for me?
Thank you,
Dima
Thank you,
Dima
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
Sorry but currently you can only use the primitive ones as mentioned above. I will add a feature request to our internal bug tracking system to allow more objects.dimabs wrote:So what is the possible solution for me?
Regards,
Peter
Ranorex Team
Re: How to invoke java method
Thanks. Hopefully, in the near future, it will be implemented, as it is a key for Java Applet UI based automation
Thank you,
Dima
Thank you,
Dima
Re: How to invoke java method
What about a case scenario when involved java method returns an object, for instance Java Table?
Thank you,
Dima
Thank you,
Dima
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
Hi,
This is not possible at the moment, you can just handle data types like int, string, bool, or null.
Peter has already added a feature request to support more data types.
Regards,
Markus
Ranorex Support Team
This is not possible at the moment, you can just handle data types like int, string, bool, or null.
Peter has already added a feature request to support more data types.
Regards,
Markus
Ranorex Support Team
Re: How to invoke java method
Hi ,
Could you please provide some additional examples / sample code
on how exactly to use this ,
since based on the example / outline provided
the codes does not compile at all.
for eg.
how do i use this to call the IsPrinting function for the JideTable object ?
http://www.jidesoft.com/javadoc/com/jid ... lePrinting()
Regards,
Prad
Could you please provide some additional examples / sample code
on how exactly to use this ,
since based on the example / outline provided
the codes does not compile at all.
for eg.
how do i use this to call the IsPrinting function for the JideTable object ?
http://www.jidesoft.com/javadoc/com/jid ... lePrinting()
Regards,
Prad
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
Hi,
Are you sure you sent us the right link, because I can't find the specific isPrinting method?
You can also try to use the InvokeMethod of the specific java control, for additional information please take a look at our .Net Api Documentation, just click, in Ranorex Studio, on Help->Api .Net Documentation.
Regards,
Markus
Ranorex Support Team
Are you sure you sent us the right link, because I can't find the specific isPrinting method?
You can also try to use the InvokeMethod of the specific java control, for additional information please take a look at our .Net Api Documentation, just click, in Ranorex Studio, on Help->Api .Net Documentation.
Regards,
Markus
Ranorex Support Team
Re: How to invoke java method
The link is fine ,
its just that when you click on the link , it misses the closing parenthesis
http://www.jidesoft.com/javadoc/com/jid ... lePrinting()
that function was just for a reference as a test function
It would be of help if you can send me an example of how to use the InvokeMethod ,
since even when all the references are included , i am unable to resolve the InvokeMethod API ,
and get an error stating Ranonrex.Core.element does not contain a definition for "InvokeMethod"
Thanks & Regards,
Prad
its just that when you click on the link , it misses the closing parenthesis
http://www.jidesoft.com/javadoc/com/jid ... lePrinting()
that function was just for a reference as a test function
It would be of help if you can send me an example of how to use the InvokeMethod ,
since even when all the references are included , i am unable to resolve the InvokeMethod API ,
and get an error stating Ranonrex.Core.element does not contain a definition for "InvokeMethod"
Thanks & Regards,
Prad
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
Hi,
I created a small sample solution where you can see how to invoke a Java method. The files are attached.
Please also note that the API had changed, so the method Tobias mentioned had also changed, for additional information take a look at our online .Net Api.
Regards,
Markus
Ranorex Support Team
I created a small sample solution where you can see how to invoke a Java method. The files are attached.
Please also note that the API had changed, so the method Tobias mentioned had also changed, for additional information take a look at our online .Net Api.
Regards,
Markus
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.
Re: How to invoke java method
Hi Markus ,
Thanks for the update , was able to use your example as reference and use this function .
but if the return value is an internal java object ,
is there an example on how to use /case that java object and call functions in that object .
should the definition of the returned object be loaded / created in the project ,
if yes ,
how to define or inherit java objects in ranorex ?
Thanks & Regards,
Pradeep
Thanks for the update , was able to use your example as reference and use this function .
but if the return value is an internal java object ,
is there an example on how to use /case that java object and call functions in that object .
should the definition of the returned object be loaded / created in the project ,
if yes ,
how to define or inherit java objects in ranorex ?
Thanks & Regards,
Pradeep
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to invoke java method
If the returned object is a java class instance,
the returned value is a JavaObjectWrapper (in Ranorex.Plugin namespace)
You can call the same methods (GetProperty, InvokeMethod, ...) on JavaObjectWrapper.
But this object has no representation in the Ranorex Element tree (like the JavaElement has)
For example:
Ranorex Team
the returned value is a JavaObjectWrapper (in Ranorex.Plugin namespace)
You can call the same methods (GetProperty, InvokeMethod, ...) on JavaObjectWrapper.
But this object has no representation in the Ranorex Element tree (like the JavaElement has)
For example:
var javaObj = (JavaObjectWrapper)javaElement.GetPropertyValue("YourComplexProperty"); var name = (string)javaObject.GetPropertyValue("SomeStringProperty"); //or, for example: javaObject.InvokeMethod("DoSomething", 1, true);Michael,
Ranorex Team
Re: How to invoke java method
Hi ,
Thanks for the response , it helps ,
but how would this work when the return value is just not one class instance
but an array of class instances ,
could you please provide some info/examples on how to loop on each object
and execute an invokeMethod/Invoke on each of the elements in the array
Thanks & Regards,
Pradeep
Thanks for the response , it helps ,
but how would this work when the return value is just not one class instance
but an array of class instances ,
could you please provide some info/examples on how to loop on each object
and execute an invokeMethod/Invoke on each of the elements in the array
Thanks & Regards,
Pradeep