Dragging mouse on the screen
Hi,
Not sure if anyone has encountered this issue, but I have a webapp where I need to swipe between screens (i.e drag the mouse from one side to another).
I've tried using:
browser.actions().mouseMove({x:0, y:300}).mouseMove({x:200, y:300}).perform();
but that doesn't seem to do anything, and I don't get any errors. Does anyone have any suggestions?
Any help would be appreciated.
Hi
if you want to 'drag' - that is typically (MouseMove->)MouseDown->MouseMove->MouseUp.
Try adding mouseUp and mouseDown.
Have a look here for Actions API: https://code.google.com/p/selenium/source/browse/javascript/webdriver/actionsequence.js
The only thing is i want to move it left and right, thus the coordinates. Any suggestions for that?
I've also tried the following:
browser.actions().mouseDown().mouseMove({x:300, y:200}).mouseMove({x:0, y:200}).mouseUp().perform().then(function() {
var text = element(by.tagName('html')).getText();
expect(text).toContain('Buying');
});
and that doesn't seem to work either.
Drag + drop is hard to work with - collecting these issues under master #1205
var plot0 = ptor.element(protractor.By.id('')); ptor.driver.actions() .dragAndDrop(plot0, {x: 100, y: 100}) .mouseMove(plot0, {x: 100, y: 100}) // 100px from left, 100 px from top of plot0 .mouseDown() .mouseMove({x: 400, y: 0}) // 400px to the right of current location .perform();
I figured out how to draw a rectangular loop on the screen with simulated mouse down, drags, and mouse up:
browser.driver.actions()
.mouseDown(graphElement)
.mouseMove({ x: 200, y: 0 })
.mouseMove({ x: 0, y: 200 })
.mouseMove({ x: -200, y: 0 })
.mouseMove({ x: 0, y: -200 })
.mouseMove({ x: 200, y: 0 })
.mouseUp()
.perform();
(see API)