1

I am trying to create a RAP application that needs to move the cursor pointer to a certain position during a game.

Is there a way, using SWT, to move the cursor position? Obviously the java.awt.Robot().mouseMove is not valid in this case because it uses AWT.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
daniel sp
  • 937
  • 1
  • 11
  • 29
  • If you feel an answer solved the problem, please mark it as 'accepted' by clicking the green checkmark. This helps keep the focus on older posts which still don't have answers. – Rüdiger Herrmann Aug 27 '18 at 16:19
  • Solving the problem, I wouldn't say so; it doesn't solve my problem. However, answering it yes. I'll mark it as 'Accepted', as soon as I test the setCursorLocation and see it doesn't work when usingin RAP. – daniel sp Aug 28 '18 at 06:01
  • Could you describe why exactly you want to change the mouse cursor position? – Rüdiger Herrmann Aug 28 '18 at 07:37
  • I have an old application that performs automated tests. Its GUI is currently a Swing application that uses the Robot class to perform the pre-configured tests: I.e open this application and type this or click here or there using image recognition. I was thinking on migrating it into SWT / RAP, if that was possible, for automated tests on web sites. Of course since is no way, using javascript, to move the cursor around I guess it means it can't also be done in RAP. – daniel sp Aug 28 '18 at 08:11
  • Please see my edits to the answer. Now that your question has become an entirely different one, you may want to post it as a separate question. – Rüdiger Herrmann Sep 02 '18 at 14:19
  • My question is not entirely different. It remains the same. I want to move the cursor around the desktop by controlling it from the browser. I see it is not possible. I am not trying to test RAP or SWT or use Selenium. – daniel sp Sep 03 '18 at 06:24

1 Answers1

1

RAP does not support changing the cursor location.

Display::getCursorLocation allows to query the (last known) cursor location, but there setCursorLocation, which is available in SWT is not implemented by RAP.

Even if there was an API server-side, I doubt that the client security policy would allow to mess the mouse pointer position.


Addressing your comment, for end-to-end testing RAP UIs you may want to look at this post: https://eclipsesource.com/blogs/2014/04/29/how-to-write-ui-tests-for-rap-with-selenium-2-0/ that describes how to set up Selenium UI tests for RAP applications.

In my experience it is best to separate the UI from the rest of your application code so that the UI layer becomes so thin that it is safe enough to go without automated tests.

Another way to test SWT or RAP UIs is to expose the relevant widgets to the test code and use Widget::notifyListeners to simulate user interaction. Again this works best if your application logic is cleanly separated and can be replaced with tests doubles while testing.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • My application is not performing tests for RAP or SWT in particular. The application is performing tests using computer vision for any application in your system. For example, you can record a 'test' that consists on opening MS Word, by clicking in its icon in your desktop, then typing something and then saving it with a name. Then when you press play in my application, it will do the same by taking screenshots and processing them to find the places the action took place before. What I am trying to migrate is the GUI that looks old and I was exploring if it could be done with a web technology. – daniel sp Sep 03 '18 at 06:22
  • Your question starts with 'trying to create a RAP application [...] to move the cursor pointer'. If that's not what you are looking for, then please rewrite the question accordingly or post a new one. I think it may help others too if there was a concise questions with a matching answer. – Rüdiger Herrmann Sep 03 '18 at 07:15