UNPKG

2.69 kBPlain TextView Raw
1import { expectError, expectType } from 'tsd';
2import { Awaitable, NightwatchAPI } from '..';
3import { WebElement } from 'selenium-webdriver';
4
5// Expect test for language chains
6
7it('actions.press', () => {
8 browser.perform(() => {
9 return browser.actions().press();
10 });
11});
12
13it('actions.release', () => {
14 browser.perform(() => {
15 return browser.actions().release();
16 });
17});
18
19it('actions.mouse', () => {
20 browser.perform(() => {
21 return browser.actions().mouse();
22 });
23});
24
25it('actions.keyboard', () => {
26 browser.perform(() => {
27 return browser.actions().keyboard();
28 });
29});
30
31it('actions.move', () => {
32 browser.perform(() => {
33 return browser.actions().move({ x: 100, y: 200 });
34 });
35});
36
37it('actions.clear', () => {
38 browser.perform(() => {
39 return browser.actions().clear();
40 });
41});
42
43it('actions.pause', () => {
44 browser.perform(() => {
45 return browser.actions().pause();
46 });
47});
48
49it('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
65it('actions.doubleClick', () => {
66 browser.perform(() => {
67 return browser.actions().doubleClick();
68 });
69});
70
71it('actions.contextClick', () => {
72 browser.perform(() => {
73 return browser.actions().contextClick();
74 });
75});
76
77it('actions.keyDown', () => {
78 browser.perform(() => {
79 return browser.actions().keyDown('CONTROL');
80 });
81});
82
83it('actions.keyUp', () => {
84 browser.perform(() => {
85 return browser.actions().keyUp('CONTROL');
86 });
87});
88
89it('actions.sendKeys', () => {
90 browser.perform(() => {
91 return browser.actions().sendKeys();
92 });
93});
94
95it('actions.perform', () => {
96 browser.perform(() => {
97 browser.actions().sendKeys().perform();
98 });
99});
100
101it('actions.options.async.bridge', () => {
102 browser.perform(() => {
103 return browser.actions({ async: true, bridge: true }).sendKeys();
104 });
105});
106
107it('actions.options.async', () => {
108 browser.perform(() => {
109 return browser.actions({ async: true }).sendKeys();
110 });
111});
112
113it('actions.options.bridge', () => {
114 browser.perform(() => {
115 return browser.actions({ bridge: true }).sendKeys();
116 });
117});