4

In a particular scenario I have to get full control of my mouse and with the actions() class I'm not able to do it.

In my application there is a map and there is a functionality, which uses lasso to select certain portion of the map (say we draw a circle with lasso and selection is represented by a red circle), then only a pop up comes for further navigation, but when I use actions class like below

var loc = element(by.xpath("//span[@id='imgLasso']"));
browser.actions()
    .mouseMove(loc, {x: 550, y: 436}) 
    .mouseDown()
    .mouseMove({x: 700, y: 236})
    .perform();

actual mouse movement doesn't occur and I found no solution, except using Java robot class, hence I want to create a batch file, which calls a Java class with robot methods in it, but I'm not sure how to do it.


UPDATE

it("working with lasso",function() {
    browser.sleep(5000);
    element(by.xpath("//span[@id='imgLasso']")).click();
    var plot0 = element(by.xpath("//span[@id='imgLasso']"));
    browser.sleep(2000); // intentional wait
    browser.actions()
        .mouseMove({x: 100, y: 100})
        .mouseDown()
        .mouseMove({x: 400, y: 0})
        .perform();

    browser.sleep(8000);
    element(by.xpath("//*[@id='imputTerritory']")).sendKeys("NewTeritory");
});

on execution of the code above, here are my observations:

  1. Till var plot0 line, code is executed normally.
  2. After that browser.action()... get executed only just before Chrome is closed by protractor. Don't know why. (also I have included sleep to verify that)
  3. Also just before Chrome is closed I can see a straight red line on the map, but not followed by any pop up (it's possible the mouse is not released by actions class)

Just to add this time I'm not passing any plot0 element in the code, I'm just keeping my mouse pointer on the map manually, just before above spec is executed.

user7637745
  • 965
  • 2
  • 14
  • 27
Rajnish Kumar
  • 2,828
  • 5
  • 25
  • 39
  • 1
    Have you tried `browser.actions().dragAndDrop(...).perform()`? – alecxe Mar 09 '16 at 13:57
  • @ alecxe i tried browser.actions().dragAndDrop(plot0,{x: 400, y: 500}).perform(); but no help but when i do like this browser.actions() .mouseMove(plot0, {x: 100, y: 100}) .mouseDown() .mouseMove({x: 400, y: 0}) .perform(); here are my observations 1.above code executes just before chrome is closed by protractor 2.above code works as i can see a red straight line which blinks just before chrome is closed but no pop up window get opens (functionality of app on draw of line,circle or sth).is it possible above code do not release mouse. – Rajnish Kumar Mar 10 '16 at 07:19
  • Yes, you need a command to release the mouse button in your chain – martin770 Jul 01 '16 at 15:53

1 Answers1

0

I think you're missing mouseUp event in your chain

Sergey Pleshakov
  • 7,964
  • 2
  • 17
  • 40