We have a Java awt desktop application on Windows machine. We have provided a button with hyperlink to third party web based application .
Click on button should do following :
Launch new instance of Internet Explorer on the machine.
Open the URL of third party application in IE
Submit few parameters and their values using http "POST" method in IE.
It will open the application in Browser and user will work in new Window with no further interaction with Java application.
We are able to achieve this using java.awt.Desktop.browser in "GET" method . But due to security restrictions we are not supposed to pass these parameters using GET method as they are visible in URL.
I have received some suggestions to do this by using intermediate vbscript but can it be achieved within Java .
Unfortunatelly I cannot help you with invoking IE with POST and to be honnest not sure if it is even possible via vbscript. But if you have some vbscript capable of doing such thing, you can allways invoke it from java see commons-exec library. By platform invoke you can also invoke any platform special stuff - see JNA in https://github.com/java-native-access/jna
But maybe another approach - why not use encryption and hmac verification of your parameters ? When you carefully use them, you can use GET also.
Related
I want to verify API calls/json files that are generated at the time of performing action like save, edit from browser. We can see those API calls in Developers Tool of chrome browser under network Tab.
So I want to Test those API calls using Selenium. How can I achieve this ?
Thank you in Advance.
Selenium doesn't have a built in functionality for you to achieve that.
Basically, if you click the Save button from browser using Selenium, you could only get the requests and responses using a 3rd party library like the Fiddler API.
Another way for you to do that is to create the requests yourself using the HTTPRequest or HTTPResponse classes (these are in C#, probably that in Java they have a different but similar name).
And using a tool, I suggest doing it with JMeter, it's open source, can do it by himself or can be integrated with Selenium.
Another options, "Selenium based" would be to use a headless browser. I know that HTMLUnitDriver has this built in, not sure about PhantomJS or others.
I'm using SWT.Browser (java) and am wondering if there's a way to get a listener that hears when ajax requests are made, received, etc.
Is there a way to intercept them and manipulate them before they come in, etc?
No, there is no publicly available API for that.
However, you can write APP plugin for SWT, though it is applicable to IE only. Or for Firefox or Webkit or IE you can write a local proxy like fiddler.
I'm looking for a way to launch my java application when using a custom URI.
Something in the lines of
movie://superman/
This should start my application and display information about the movie "Superman".
if friends of my have my application installed as well, i can send them that URI so they can click on it.
I used to do this back in the days in VB6 but i lost my code and forgot how to do it.
OS: windows
Any help would be appreciated.
The actual mechanism to implement this is operating-system dependent (and thus not accessible from pure Java).
The general idea is to register your application as the protocol handler for the protocol in question.
On Windows you do that by writing the appropriate registry keys
..should start my application and display information about the movie "Superman".
If you can distribute your app. from a web site, you might take a slightly different approach:
Launch the app. using Java Web Start.
In the JWS launch file (JNLP format), add a custom file extension, e.g. xuri.
Send the user an clickthis.xuri file containing the URI of interest.
When the JWS app. registered to that file type is invoked, it will be passed -open clickthis.xuri as arguments to the main(String[]).
Proceed from there..
This approach should work on any OS with 'modern' Java installed. JWS was available since 1.2, & became co-bundled with the JRE around 1.4.2.
How can I execute a desktop application from a browser?. I have a web page with a button, when user click this button a simple java desktop application must run. How can I do this using jsp or javascript?
Java Web Start might be your solution.
To start a Java Web Start application, you simply direct the browser to the location of the JNLP file. Basically, the browser detects that instead of simply downloading the file, it should run it in Web Start.
Most major browsers support Java Web Start. Java Web Start is cross platform (works on Mac and PC).
So, in Javascript, it's done simply like this:
window.location = "http://www.examples.com/myapp.jnlp";
You'll also need to sign your Java application, or the user will get a nasty warning.
You should take a look at the Java Web Start technology.
This would be the closest thing: Java Web Start
Managing this through Applets is another option though the underlying scheme is the same, the user needs to accept the generated certificate.
I have a windows application which has a complex GUI that I would like to hide from users. In order to do this, I would like to create a wrapper with an extremely simple interface that overlays this application and automates a number of actions when a user clicks a single button on the wrapper. (I hope "wrapper" is the proper term.) Is it possible to use Java to block input to the underlying application so that users cannot inadvertently mess up the automation? How would I go about this? Also, how can I automate key presses and clicks to the application without hijacking the mouse? Is this possible in Java?
I have looked at java.awt.Robot, but it appears to hijack the mouse.
I have also looked at AutoIT, but it too hijacks the mouse and does not integrate with Java.
Neither of these options seem powerful enough for what I need, but I do not know how else to proceed.
I recommend that automation via the GUI only as the last resort if you really have no other alternative.
If there is an API that your application exposes, I would try to use that. For example, if the GUI is implemented in one DLL and the logic in another, then you can use JNA to load your application logic DLL and invoke the application functions directly from java. Even better would be if your application exposes a COM/OLE interface - there are plenty of Java<>COM briges, that will alow you to call this interface directly, e.g. Jacob.
If you really have no choice but to automate via the GUI, then here's how to go about doing that:
Use JNA to access the windows shell API. You can then use ShellExecute to launch your wrapped application. Specifically, passing SW_HIDE as the window mode should help ensure that the application does not appear.
Use JNA to access the windows API FindWindow to find your application window. You can also make it invisible using the ShowWindow API, just in case step 1 did not work (not all applications are written to use the nCmdShow parameter.)
You can now post messages to the application window using PostMessage. You can send keystrokes and mouse events using windows messages. E.g. See WM_KEYUP, WM_LBUTTONDOWN.
Because the wrapped application window is made invisible, you don't need to "block" that application, The user simply cannot access it's GUI. But you can still programmatically send input to it.