Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
29
rated 0 times [  34] [ 5]  / answers: 1 / hits: 25220  / 9 Years ago, tue, february 24, 2015, 12:00:00

Is it possible to move the mouse to arbitrary coordinates on the screen/relative to an element in Protractor tests? I see people recommend using Robot for Java users, but of course I can't use that in JavaScript.


More From » selenium

 Answers
21

I figured it out for myself...just took some deep digging through Protractor and Selenium documentation. Here is some example code:



  it('should pan plots when you click and drag', function() {
var plot0 = element(by.css('.plot > canvas'));
browser.actions()
.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();
});

[#67687] Monday, February 23, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaelyn

Total Points: 619
Total Questions: 102
Total Answers: 104

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;