1 | import { expectError, expectType } from 'tsd';
|
2 | import { Awaitable, NightwatchAPI } from '..';
|
3 | import { WebElement } from 'selenium-webdriver';
|
4 |
|
5 |
|
6 |
|
7 | it('actions.press', () => {
|
8 | browser.perform(() => {
|
9 | return browser.actions().press();
|
10 | });
|
11 | });
|
12 |
|
13 | it('actions.release', () => {
|
14 | browser.perform(() => {
|
15 | return browser.actions().release();
|
16 | });
|
17 | });
|
18 |
|
19 | it('actions.mouse', () => {
|
20 | browser.perform(() => {
|
21 | return browser.actions().mouse();
|
22 | });
|
23 | });
|
24 |
|
25 | it('actions.keyboard', () => {
|
26 | browser.perform(() => {
|
27 | return browser.actions().keyboard();
|
28 | });
|
29 | });
|
30 |
|
31 | it('actions.move', () => {
|
32 | browser.perform(() => {
|
33 | return browser.actions().move({ x: 100, y: 200 });
|
34 | });
|
35 | });
|
36 |
|
37 | it('actions.clear', () => {
|
38 | browser.perform(() => {
|
39 | return browser.actions().clear();
|
40 | });
|
41 | });
|
42 |
|
43 | it('actions.pause', () => {
|
44 | browser.perform(() => {
|
45 | return browser.actions().pause();
|
46 | });
|
47 | });
|
48 |
|
49 | it('actions.dragAndDrop', () => {
|
50 | browser.perform(async () => {
|
51 | const sampleElement = element('.element-class');
|
52 | const webElement = await sampleElement.getWebElement();
|
53 | browser.actions().dragAndDrop(webElement, { x: 12, y: 234 });
|
54 |
|
55 | const webElement2 = sampleElement.findElement();
|
56 | expectType<Awaitable<NightwatchAPI, WebElement>>(webElement2);
|
57 | expectError(browser.actions().dragAndDrop(webElement2, { x: 12, y: 234 }));
|
58 | browser.actions().dragAndDrop(await webElement2, { x: 12, y: 234 });
|
59 |
|
60 | const webElement3 = await sampleElement.findElement('something');
|
61 | return browser.actions().dragAndDrop(webElement3, { x: 12, y: 234 });
|
62 | });
|
63 | });
|
64 |
|
65 | it('actions.doubleClick', () => {
|
66 | browser.perform(() => {
|
67 | return browser.actions().doubleClick();
|
68 | });
|
69 | });
|
70 |
|
71 | it('actions.contextClick', () => {
|
72 | browser.perform(() => {
|
73 | return browser.actions().contextClick();
|
74 | });
|
75 | });
|
76 |
|
77 | it('actions.keyDown', () => {
|
78 | browser.perform(() => {
|
79 | return browser.actions().keyDown('CONTROL');
|
80 | });
|
81 | });
|
82 |
|
83 | it('actions.keyUp', () => {
|
84 | browser.perform(() => {
|
85 | return browser.actions().keyUp('CONTROL');
|
86 | });
|
87 | });
|
88 |
|
89 | it('actions.sendKeys', () => {
|
90 | browser.perform(() => {
|
91 | return browser.actions().sendKeys();
|
92 | });
|
93 | });
|
94 |
|
95 | it('actions.perform', () => {
|
96 | browser.perform(() => {
|
97 | browser.actions().sendKeys().perform();
|
98 | });
|
99 | });
|
100 |
|
101 | it('actions.options.async.bridge', () => {
|
102 | browser.perform(() => {
|
103 | return browser.actions({ async: true, bridge: true }).sendKeys();
|
104 | });
|
105 | });
|
106 |
|
107 | it('actions.options.async', () => {
|
108 | browser.perform(() => {
|
109 | return browser.actions({ async: true }).sendKeys();
|
110 | });
|
111 | });
|
112 |
|
113 | it('actions.options.bridge', () => {
|
114 | browser.perform(() => {
|
115 | return browser.actions({ bridge: true }).sendKeys();
|
116 | });
|
117 | });
|