6

I am writing a chrome extension that records your actions like ( mouse click, keyboard keyup ). The idea of the extension is to help me and my colleagues to reduce the boring testing of our web based project. I made it to record the events and store it on the dev server as mysql so i can use or share to them. But the problem is replaying the saved actions.

So how if there is a way to force mouse move, mouse click events. Can it be done from flash,java or something like that.

PS. The project is Extjs but i want to make the extension useful for developer using other frameworks and publish it.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
mraiur
  • 136
  • 1
  • 2
  • 6

2 Answers2

2

Consider using Selenium for this. It has support for many languages, and you can script your whole test with it. You can for example set it to click on an element, wait for something to happen or fill text boxes.

Veda
  • 2,025
  • 1
  • 18
  • 34
1

Imagine some random website controlling your mouse ... not cool, is it? (That's why you cant force mousemove via javascript)

However, you can trigger clicks on elements. To achieve that, you need to save the event(mouse-over|out/(dbl)click/whatever) and the according element (in the eventfunction: this). That should be sufficient to simulate theworkflow.

jQuery-Example:

$('#item').click();
$('#item').trigger('click');

vanilla javascript:

document.querySelector("#item").click();
Christoph
  • 50,121
  • 21
  • 99
  • 128
  • If you need to simulate mouse move events you can trigger them to: http://stackoverflow.com/questions/911586/javascript-simulate-mouse-over-in-code – Konrad Dzwinel Jun 11 '12 at 09:52
  • You are right but the problem is extjs for example creates ID dynamically and cant save the action as "this id -> click". And иi thought that chrome allows controlling the mouse from an extension(because the user/developer allowed the extension to be installed ). – mraiur Jun 11 '12 at 10:11
  • @mraiur It might be that chrome extensions allow controlling the mouse, though i highly doubt that. However, since the events have coordinates attached to them, you could try to locate the element which is at this position and trigger a click once it has been determined. But i see a lot of potential problems arising with that method. – Christoph Jun 11 '12 at 10:21