I am writing a functional test automation script to automate the file upload feature of a web application. I am using a tool called selenium to operate on the browser. This tool however does not support clicking on the file upload control hence I want to do this operation using java robot.

First I need to move the mouse pointer onto the html element (file upload control) displayed within a html page. I believe to do that i need to get the coordinates of the html element. I tried with the offsetLeft and offsetTop but those are just the relative coordinates (relative to the html document). I need the absolute screen coordinates. Is there a way to get the absolute screen coordinates? If not can you suggest a different approach?

Thanks for reading

10-30-2009, 07:47 AM

travishein

my first thought was you can't move the mouse cursor from a java application,
however, it likely could be possible to create a kind of custom vnc viewer client,. where by the host doing the test runs a vnc serer, and your java test automation script implements a stripped down vnc viewer client, such as one that is written in java (tightvnc has one). there is a lot of nitty gritty details in the RFB protocol, but certianly you could jerry rig something that connects a client to the local host and doesn't open a display, and just invokes the mouse move position messages to the vncserver, moving the mouse to the button to be tested.
other similar ideas, projects like X2vnc, win2vnc where a network client on your machine can drive the keyboard and mouse on a second or more computer running vnc, such as if it was beside you and you wanted to have one control for more than one desktop.
another project i know of that does this kind of keyboard mouse control is synergy.
the trick is, to find some kind of network based remote control software, and have a java client communicate in that network protocol, and instead of showing the remote desktop display, or having the host's keyboard and mouse move the controlled system, it would just move teh mouse according to a trained test plan.