Skip to content

Commit 33781b5

Browse files
Update tests
1 parent 8d92568 commit 33781b5

File tree

5 files changed

+61
-63
lines changed

5 files changed

+61
-63
lines changed

test/e2e/commands/file-movement-e2e-specs.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,7 @@ import { remote as wdio } from 'webdriverio';
22
import path from 'path';
33
import { tempDir, fs } from 'appium/support';
44
import { isAdmin } from '../../../lib/installer';
5-
import { TEST_HOST, TEST_PORT } from '../constants';
6-
7-
8-
const TEST_CAPS = {
9-
platformName: 'Windows',
10-
'appium:automationName': 'windows',
11-
'appium:app': 'Root',
12-
};
13-
14-
const WDIO_OPTS = {
15-
hostname: TEST_HOST,
16-
port: TEST_PORT,
17-
connectionRetryCount: 0,
18-
capabilities: TEST_CAPS
19-
};
5+
import { buildWdIoOptions } from '../helpers';
206

217
describe('file movement', function () {
228
let driver;
@@ -36,7 +22,7 @@ describe('file movement', function () {
3622
return this.skip();
3723
}
3824

39-
driver = await wdio(WDIO_OPTS);
25+
driver = await wdio(buildWdIoOptions('Root'));
4026
});
4127

4228
afterEach(async function () {

test/e2e/commands/winapi-e2e-specs.js

+36-29
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,61 @@
1-
import * as commands from '../../../lib/commands/gestures';
2-
import { log } from '../../../lib/logger';
3-
1+
import { buildWdIoOptions } from '../helpers';
2+
import { remote as wdio } from 'webdriverio';
43

54
describe('winapi', function () {
65
let chai;
6+
let driver;
77

88
before(async function () {
99
chai = await import('chai');
1010
const chaiAsPromised = await import('chai-as-promised');
1111

1212
chai.should();
1313
chai.use(chaiAsPromised.default);
14-
commands.log = log;
14+
15+
driver = await wdio(buildWdIoOptions('Root'));
1516
});
1617

17-
after(function () {
18-
delete commands.log;
18+
after(async function () {
19+
try {
20+
if (driver) {
21+
await driver.deleteSession();
22+
}
23+
} finally {
24+
driver = null;
25+
}
1926
});
2027

2128
describe('mouseClick', function () {
2229
it('performs single click with Shift+Ctrl', async function () {
23-
await commands.windowsClick({
30+
await driver.execute('windows: click', [{
2431
x: 100,
2532
y: 100,
2633
modifierKeys: ['shift', 'ctrl'],
27-
});
34+
}]);
2835
});
2936

3037
it('performs long click', async function () {
31-
await commands.windowsClick({
38+
await driver.execute('windows: click', [{
3239
x: 100,
3340
y: 100,
3441
durationMs: 500,
35-
});
42+
}]);
3643
});
3744

3845
it('performs double click', async function () {
39-
await commands.windowsClick({
46+
await driver.execute('windows: click', [{
4047
x: 100,
4148
y: 100,
4249
times: 2,
43-
});
50+
}]);
4451
});
4552

4653
it('performs context click', async function () {
47-
await commands.windowsClick({
54+
await driver.execute('windows: click', [{
4855
x: 100,
4956
y: 100,
5057
button: 'right',
51-
});
58+
}]);
5259
});
5360

5461
it('fails if wrong input is provided', async function () {
@@ -84,35 +91,35 @@ describe('winapi', function () {
8491
];
8592

8693
for (const errData of errDatas) {
87-
await commands.windowsClick(errData).should.be.rejected;
94+
await driver.execute('windows: click', [errData]).should.be.rejected;
8895
}
8996
});
9097
});
9198

9299
describe('mouseScroll', function () {
93100
it('performs vertical scroll gesture with Ctrl+Alt depressed', async function () {
94-
await commands.windowsScroll({
101+
await driver.execute('windows: scroll', [{
95102
x: 600,
96103
y: 300,
97104
deltaY: 200,
98105
modifierKeys: ['ctrl', 'alt'],
99-
});
106+
}]);
100107
});
101108

102109
it('performs horizontal scroll gesture', async function () {
103-
await commands.windowsScroll({
110+
await driver.execute('windows: scroll', [{
104111
x: 600,
105112
y: 300,
106113
deltaX: -200,
107-
});
114+
}]);
108115
});
109116

110117
it('does nothing if zero delta is provided', async function () {
111-
await commands.windowsScroll({
118+
await driver.execute('windows: scroll', [{
112119
x: 100,
113120
y: 100,
114121
deltaY: 0,
115-
});
122+
}]);
116123
});
117124

118125
it('fails if wrong input is provided', async function () {
@@ -136,38 +143,38 @@ describe('winapi', function () {
136143
];
137144

138145
for (const errData of errDatas) {
139-
await commands.windowsScroll(errData).should.be.rejected;
146+
await driver.execute('windows: scroll', [errData]).should.be.rejected;
140147
}
141148
});
142149
});
143150

144151
describe('mouseClickAndDrag', function () {
145152
it('performs drag gesture with Ctrl+Shift depressed', async function () {
146-
await commands.windowsClickAndDrag({
153+
await driver.execute('windows: clickAndDrag', [{
147154
startX: 600,
148155
startY: 300,
149156
endX: 500,
150157
endY: 400,
151158
modifierKeys: ['ctrl', 'shift'],
152-
});
159+
}]);
153160
});
154161
});
155162

156163
describe('windowsHover', function () {
157164
it('performs hover gesture with Ctrl+Shift depressed', async function () {
158-
await commands.windowsHover({
165+
await driver.execute('windows: clickAndDrag', [{
159166
startX: 600,
160167
startY: 300,
161168
endX: 500,
162169
endY: 400,
163170
modifierKeys: ['ctrl', 'shift'],
164-
});
171+
}]);
165172
});
166173
});
167174

168175
describe('keys', function () {
169176
it('performs complex key input', async function () {
170-
await commands.windowsKeys({
177+
await driver.execute('windows: keys', [{
171178
actions: [
172179
{virtualKeyCode: 0x10, down: true},
173180
{pause: 100},
@@ -176,7 +183,7 @@ describe('winapi', function () {
176183
{pause: 100},
177184
{virtualKeyCode: 0x10, down: false},
178185
]
179-
});
186+
}]);
180187
});
181188

182189
it('fails if wrong input is provided', async function () {
@@ -199,7 +206,7 @@ describe('winapi', function () {
199206
];
200207

201208
for (const errData of errDatas) {
202-
await commands.windowsKeys(errData).should.be.rejected;
209+
await driver.execute('windows: keys', [errData]).should.be.rejected;
203210
}
204211
});
205212
});

test/e2e/constants.js

-2
This file was deleted.

test/e2e/driver-e2e-specs.js

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import { remote as wdio } from 'webdriverio';
22
import { isAdmin } from '../../lib/installer';
3-
import { TEST_HOST, TEST_PORT } from './constants';
4-
5-
6-
const TEST_CAPS = {
7-
platformName: 'Windows',
8-
'appium:automationName': 'windows',
9-
'appium:app': 'Microsoft.WindowsCalculator_8wekyb3d8bbwe!App',
10-
};
11-
12-
const WDIO_OPTS = {
13-
hostname: TEST_HOST,
14-
port: TEST_PORT,
15-
connectionRetryCount: 0,
16-
capabilities: TEST_CAPS
17-
};
3+
import { buildWdIoOptions } from './helpers';
184

195
describe('Driver', function () {
206
let driver;
@@ -33,7 +19,7 @@ describe('Driver', function () {
3319
return this.skip();
3420
}
3521

36-
driver = await wdio(WDIO_OPTS);
22+
driver = await wdio(buildWdIoOptions('Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'));
3723
});
3824

3925
afterEach(async function () {

test/e2e/helpers.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const TEST_PORT = parseInt(process.env.APPIUM_TEST_SERVER_PORT || 4788, 10);
2+
export const TEST_HOST = process.env.APPIUM_TEST_SERVER_HOST || '127.0.0.1';
3+
4+
5+
/**
6+
*
7+
* @param {string} app
8+
* @returns {Record<string, any>}
9+
*/
10+
export function buildWdIoOptions(app) {
11+
return {
12+
hostname: TEST_HOST,
13+
port: TEST_PORT,
14+
connectionRetryCount: 0,
15+
capabilities: {
16+
platformName: 'Windows',
17+
'appium:automationName': 'windows',
18+
'appium:app': app,
19+
}
20+
};
21+
}

0 commit comments

Comments
 (0)