Skip to content

Commit 55c0ddf

Browse files
committed
[JS] Adds code sample dragAndDrop by offset
1 parent 60317cc commit 55c0ddf

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const {By} = require('selenium-webdriver');
2+
const {suite} = require('selenium-webdriver/testing');
3+
const assert = require('assert');
4+
5+
suite(function(env) {
6+
describe('Drag and Drop', function() {
7+
let driver;
8+
9+
before(async function() {
10+
driver = await env.builder().build();
11+
});
12+
13+
after(async () => await driver.quit());
14+
15+
it('By Offset', async function() {
16+
await driver.get('https://www.selenium.dev/selenium/web/mouse_interaction.html');
17+
const draggable = driver.findElement(By.id("draggable"));
18+
let start = await draggable.getRect();
19+
let finish = await driver.findElement(By.id("droppable")).getRect();
20+
const actions = driver.actions({async: true});
21+
await actions.dragAndDrop(draggable, {x: finish.x - start.x, y: finish.y-start.y}).perform();
22+
23+
let result = await driver.findElement(By.id("drop-status")).getText();
24+
assert.deepStrictEqual('dropped', result)
25+
});
26+
});
27+
});

0 commit comments

Comments
 (0)