-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathmoveByOffset.spec.js
50 lines (40 loc) · 1.92 KB
/
moveByOffset.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const {By, Origin} = require('selenium-webdriver');
const {suite} = require('selenium-webdriver/testing');
const assert = require('assert');
suite(function(env) {
describe('Mouse move by offset', function() {
let driver;
before(async function() {
driver = await env.builder().build();
});
after(async () => await driver.quit());
it('From element', async function() {
await driver.get('https://www.selenium.dev/selenium/web/mouse_interaction.html');
const mouseTracker = driver.findElement(By.id("mouse-tracker"));
const actions = driver.actions({async: true});
await actions.move({x:8, y:0, origin: mouseTracker}).perform();
await driver.sleep(500);
let result = await driver.findElement(By.id('relative-location')).getText();
result = result.split(', ');
assert.deepStrictEqual((Math.abs(parseInt(result[0]) -100 -8)<2), true)
});
it('From viewport origin', async function() {
await driver.get('https://www.selenium.dev/selenium/web/mouse_interaction.html');
const actions = driver.actions({async: true});
await actions.move({x:8, y:0}).perform();
let result = await driver.findElement(By.id('absolute-location')).getText();
result = result.split(', ');
assert.deepStrictEqual((Math.abs(parseInt(result[0]) -8)<2), true)
});
it('From current pointer location', async function() {
await driver.get('https://selenium.dev/selenium/web/mouse_interaction.html');
const actions = driver.actions({async: true});
await actions.move({x: 6, y: 3}).perform()
await actions.move({x: 13, y: 15, origin: Origin.POINTER}).perform()
let result = await driver.findElement(By.id('absolute-location')).getText();
result = result.split(', ');
assert.deepStrictEqual(Math.abs(parseInt(result[0]) - 6 -13)<2, true)
assert.deepStrictEqual(Math.abs(parseInt(result[1]) - 3 -15)<2, true)
});
});
});