Hi,
I'm testing Java Swing app.
I'm writing the auto tests with visual studio.
There is some functionality that isn't available throw Ranorex's adapters.
How can I access my app's methods? (with reflection I guess)
Thanks
How can I use my app methods for automation?
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How can I use my app methods for automation?
Hi Ivg,
I've seen that there was already a similar question asked here: http://www.ranorex.com/forum/how-to-inv ... t2320.html
Hope this helps.
Cheers,
Robin
I've seen that there was already a similar question asked here: http://www.ranorex.com/forum/how-to-inv ... t2320.html
Hope this helps.
Cheers,
Robin
Last edited by RobinHood42 on Wed Feb 03, 2016 1:26 pm, edited 1 time in total.
Re: How can I use my app methods for automation?
Hi,
I think there is a mistake with the link, it doesn't lead to other post.
I think there is a mistake with the link, it doesn't lead to other post.
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: How can I use my app methods for automation?
Hi,
I'm sorry. The link should now be correct
Cheers,
Robin
I'm sorry. The link should now be correct
Cheers,
Robin
Re: How can I use my app methods for automation?
Thanks!
On ranorex site there is a page with code examples (I can't post links because my account is new), I noticed a specific example : "Create Adapters to Access More Properties and Methods".
Will it work with Java methods too?
I can't test it, I need the class 'Ranorex.Control' but I can't find it, was it deprecated?
I've add to my project the reference and using of "Ranorex" assembly
On ranorex site there is a page with code examples (I can't post links because my account is new), I noticed a specific example : "Create Adapters to Access More Properties and Methods".
Will it work with Java methods too?
I can't test it, I need the class 'Ranorex.Control' but I can't find it, was it deprecated?
I've add to my project the reference and using of "Ranorex" assembly
Re: How can I use my app methods for automation?
The Ranorex API will help you: http://www.ranorex.com/Documentation/Ranorex/
Ranorex.Control : Adapter
It's under the Ranorex (very first) tree item.
Ranorex.Control : Adapter
It's under the Ranorex (very first) tree item.
Shortcuts usually aren't...
Re: How can I use my app methods for automation?
Thanks, but I still can't find it while working on my visual studio project, very strange.
I have 2 issues now:
1. I've searched and found that two options are available for using java methods with the Ranorex.JavaElement type.
public virtual void InvokeMethod(string name);
public object InvokeMethod(string methodName, params object[] args);
This overloading doesn't allow to invoke method without parameters, but WITH return value.
Is there any other option to do it? can you add this option please?
2. I've tried to invoke simple java method of the JComboBox type, but I always get "ActionFailedException". What am I doing wrong? What should I check?
I noticed when I'm running the program I always get this warning from Ranorex: "[Java AWT/Swing]: Failed to instrument Java process. Please make sure you have enough privileges to access the process."
I am Administrator on the computer.
So far I used only Ranorex's adapters and this warning wasn't affected me.
Is it related to the fact I can't invoke Java methods? How to solve this warning?
Thanks a lot!
I have 2 issues now:
1. I've searched and found that two options are available for using java methods with the Ranorex.JavaElement type.
public virtual void InvokeMethod(string name);
public object InvokeMethod(string methodName, params object[] args);
This overloading doesn't allow to invoke method without parameters, but WITH return value.
Is there any other option to do it? can you add this option please?
2. I've tried to invoke simple java method of the JComboBox type, but I always get "ActionFailedException". What am I doing wrong? What should I check?
I noticed when I'm running the program I always get this warning from Ranorex: "[Java AWT/Swing]: Failed to instrument Java process. Please make sure you have enough privileges to access the process."
I am Administrator on the computer.
So far I used only Ranorex's adapters and this warning wasn't affected me.
Is it related to the fact I can't invoke Java methods? How to solve this warning?
Thanks a lot!
Re: How can I use my app methods for automation?
Hi Ivg,
Just thought I'd comment on a couple of things here.
1. Regarding invoking a method without parameters, but WITH a return value, you can use the second overload,
public object InvokeMethod(string methodName, params object[] args);
The params keyword is for a variable number of arguments, include zero, which means that you can use
public object InvokeMethod(string methodName). See MSDN documentation about the params keyword at https://msdn.microsoft.com/en-us/library/w5zay9db.aspx
2.If you are receiving a warning from Ranorex about a failure to instrument the Java process, can you check if you have set up instrumentation Java applications by Ranorex? There are some directions at http://www.ranorex.com/support/user-gui ... swing.html, though that page of the User Guide does say that Java instrumentation is enabled automatically with Ranorex 5.0.0 and up.
Hope that helps,
Gabriel
Just thought I'd comment on a couple of things here.
1. Regarding invoking a method without parameters, but WITH a return value, you can use the second overload,
public object InvokeMethod(string methodName, params object[] args);
The params keyword is for a variable number of arguments, include zero, which means that you can use
public object InvokeMethod(string methodName). See MSDN documentation about the params keyword at https://msdn.microsoft.com/en-us/library/w5zay9db.aspx
2.If you are receiving a warning from Ranorex about a failure to instrument the Java process, can you check if you have set up instrumentation Java applications by Ranorex? There are some directions at http://www.ranorex.com/support/user-gui ... swing.html, though that page of the User Guide does say that Java instrumentation is enabled automatically with Ranorex 5.0.0 and up.
Hope that helps,
Gabriel
Re: How can I use my app methods for automation?
Hi log,
Thanks for your answers!
1. The overloading mechanism doesn't take in consideration the return value, so what I have is:
InvokeMethod(string)
InvokeMethod(string, params object[]);
It always takes the first option when I'm calling a method without parameters, because it's not making any sense making another method and call it without parameters, you already have it in the first method.
2. I have the latest Ranorex version (I'm using the trial version, testing it for my company)
So this link is not relavant for me.
Thanks for your answers!
1. The overloading mechanism doesn't take in consideration the return value, so what I have is:
InvokeMethod(string)
InvokeMethod(string, params object[]);
It always takes the first option when I'm calling a method without parameters, because it's not making any sense making another method and call it without parameters, you already have it in the first method.
2. I have the latest Ranorex version (I'm using the trial version, testing it for my company)
So this link is not relavant for me.
Re: How can I use my app methods for automation?
The ActionFailedException I got is my mistake: I've tried to use "InvokeMethod(string)" with a method that returns a value, that's what cause it.
So my only (and significant) problem is that for now I can't find the option to invoke java method that gets no parameters but returns a value.
This will really affect the decision if my company will purchase Ranorex, so if this option exists please let me know as soon as possible (:
Thanks!
So my only (and significant) problem is that for now I can't find the option to invoke java method that gets no parameters but returns a value.
This will really affect the decision if my company will purchase Ranorex, so if this option exists please let me know as soon as possible (:
Thanks!
Re: How can I use my app methods for automation?
Hi Ivg,
Ah yes, my mistake, resolution of overloaded methods doesn't take the return type into account. Sorry!
With regards to invoking a Java method with no parameters and a return value, I hope the Support Team can come up with something.
Thanks,
Gabriel
Ah yes, my mistake, resolution of overloaded methods doesn't take the return type into account. Sorry!
With regards to invoking a Java method with no parameters and a return value, I hope the Support Team can come up with something.
Thanks,
Gabriel
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How can I use my app methods for automation?
Hello Ivg,
You should be able to work around the issue with the following lines of code:
Please let me know if this solves the issue.
Sincerely,
Johannes
You should be able to work around the issue with the following lines of code:
Code: Select all
Object[] param = new Object[0];
JavaElement myElement = repo.Java.Self.As<JavaElement>();
var returnVal = myElement.InvokeMethod("myMethodToInvoke", param);
Sincerely,
Johannes