@camperaid/watest 2.3.0 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/series.js +26 -8
- package/index.js +2 -1
- package/package.json +2 -2
- package/tests/e2e/samples/folder/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/folder/package-lock.json +1 -2
- package/tests/e2e/samples/loader/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader/package-lock.json +1 -2
- package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader_mixed/package-lock.json +1 -2
- package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader_multiple/package-lock.json +1 -2
- package/tests/e2e/samples/single/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/single/package-lock.json +1 -2
- package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/wd_mixed/package-lock.json +1 -2
- package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/wd_single/package-lock.json +1 -2
- package/tests/series/build/t_expected_failures.js +111 -0
- package/tests/series/perform/t_intermittent_global.js +80 -0
- package/tests/webdriver/t_app_driver.js +45 -13
- package/tests/webdriver/t_select_all.js +67 -0
- package/tests/webdriver/test.js +1 -0
- package/webdriver/app_driver.js +3 -21
- package/webdriver/control_driver.js +32 -0
- package/webdriver/driver.js +10 -7
package/core/series.js
CHANGED
|
@@ -185,7 +185,13 @@ class Series {
|
|
|
185
185
|
/**
|
|
186
186
|
* Returns tests as an array of { name, func, ... } objects.
|
|
187
187
|
*/
|
|
188
|
-
async build({
|
|
188
|
+
async build({
|
|
189
|
+
patterns,
|
|
190
|
+
folder,
|
|
191
|
+
virtual_folder,
|
|
192
|
+
webdriver = '',
|
|
193
|
+
inherited_expected_failures = [],
|
|
194
|
+
}) {
|
|
189
195
|
let tests = [];
|
|
190
196
|
try {
|
|
191
197
|
let test_module = await this.loadTestMeta(folder);
|
|
@@ -195,6 +201,12 @@ class Series {
|
|
|
195
201
|
throw new Error(`No tests found in ${folder}`);
|
|
196
202
|
}
|
|
197
203
|
|
|
204
|
+
if (test_module.expected_failures) {
|
|
205
|
+
inherited_expected_failures = inherited_expected_failures.concat(
|
|
206
|
+
test_module.expected_failures.filter(v => v[0] == '**')
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
198
210
|
if (
|
|
199
211
|
!this.childProcess &&
|
|
200
212
|
!this.suppressChildProcessInitiation &&
|
|
@@ -227,7 +239,9 @@ class Series {
|
|
|
227
239
|
virtual_folder,
|
|
228
240
|
subfolders,
|
|
229
241
|
webdriver,
|
|
242
|
+
inherited_expected_failures,
|
|
230
243
|
}),
|
|
244
|
+
inherited_expected_failures,
|
|
231
245
|
});
|
|
232
246
|
}
|
|
233
247
|
|
|
@@ -271,7 +285,9 @@ class Series {
|
|
|
271
285
|
virtual_folder: wd_virtual_folder,
|
|
272
286
|
subfolders,
|
|
273
287
|
webdriver,
|
|
288
|
+
inherited_expected_failures,
|
|
274
289
|
}),
|
|
290
|
+
inherited_expected_failures,
|
|
275
291
|
});
|
|
276
292
|
if (wdtests.length > 0) {
|
|
277
293
|
tests.push({
|
|
@@ -342,6 +358,7 @@ class Series {
|
|
|
342
358
|
virtual_folder,
|
|
343
359
|
subfolders,
|
|
344
360
|
webdriver,
|
|
361
|
+
inherited_expected_failures,
|
|
345
362
|
}) {
|
|
346
363
|
if (!subfolders) {
|
|
347
364
|
return [];
|
|
@@ -354,6 +371,7 @@ class Series {
|
|
|
354
371
|
folder: `${folder}/${subfolder}`,
|
|
355
372
|
virtual_folder: `${virtual_folder}/${subfolder}`,
|
|
356
373
|
webdriver,
|
|
374
|
+
inherited_expected_failures,
|
|
357
375
|
}).then(subtests => ({
|
|
358
376
|
subfolder,
|
|
359
377
|
subtests,
|
|
@@ -385,6 +403,7 @@ class Series {
|
|
|
385
403
|
patterns,
|
|
386
404
|
webdriver,
|
|
387
405
|
subtests,
|
|
406
|
+
inherited_expected_failures,
|
|
388
407
|
}) {
|
|
389
408
|
const { include_list, exclude_list } = test_module;
|
|
390
409
|
let list = this.buildList({
|
|
@@ -402,7 +421,9 @@ class Series {
|
|
|
402
421
|
return tests;
|
|
403
422
|
}
|
|
404
423
|
|
|
405
|
-
const expected_failures =
|
|
424
|
+
const expected_failures = inherited_expected_failures.concat(
|
|
425
|
+
test_module.expected_failures || []
|
|
426
|
+
);
|
|
406
427
|
|
|
407
428
|
// Initialize
|
|
408
429
|
if (test_module.services || test_module.init) {
|
|
@@ -591,9 +612,7 @@ class Series {
|
|
|
591
612
|
} = test;
|
|
592
613
|
|
|
593
614
|
if (stop && !name.endsWith('uninit')) {
|
|
594
|
-
log(
|
|
595
|
-
`\x1b[31m!Skipped:\x1b[0m ${name}, because of previous failures\n`
|
|
596
|
-
);
|
|
615
|
+
log(`\x1b[31m!Skipped:\x1b[0m ${name}, because of previous failures\n`);
|
|
597
616
|
continue;
|
|
598
617
|
}
|
|
599
618
|
|
|
@@ -782,7 +801,7 @@ class Series {
|
|
|
782
801
|
|
|
783
802
|
static failuresInfo({ failures, webdriver, platform, testname }) {
|
|
784
803
|
let filtered_failures = failures.filter(
|
|
785
|
-
v => testname.includes(v[0]) || v[0] == '*'
|
|
804
|
+
v => testname.includes(v[0]) || v[0] == '*' || v[0] == '**'
|
|
786
805
|
);
|
|
787
806
|
|
|
788
807
|
return (
|
|
@@ -882,8 +901,7 @@ class Series {
|
|
|
882
901
|
continue;
|
|
883
902
|
}
|
|
884
903
|
|
|
885
|
-
let log_func = msg =>
|
|
886
|
-
is_stdout ? log(msg) : log_error(msg);
|
|
904
|
+
let log_func = msg => (is_stdout ? log(msg) : log_error(msg));
|
|
887
905
|
|
|
888
906
|
if (line.startsWith('console.debug')) {
|
|
889
907
|
line = line.replace(
|
package/index.js
CHANGED
|
@@ -26,7 +26,8 @@ const { inspect } = require('./core/util.js');
|
|
|
26
26
|
|
|
27
27
|
const { tmp_storage_dir } = require('./core/settings.js');
|
|
28
28
|
|
|
29
|
-
const { AppDriver
|
|
29
|
+
const { AppDriver } = require('./webdriver/app_driver.js');
|
|
30
|
+
const { ControlDriver } = require('./webdriver/control_driver.js');
|
|
30
31
|
const { start_session, scope } = require('./webdriver/session.js');
|
|
31
32
|
|
|
32
33
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camperaid/watest",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "Web Application Testsuite",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.15.1"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"watest": "./bin/watest.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
14
|
+
"prepare": "bash tests/install.sh",
|
|
15
15
|
"lint": "eslint '**/*.js'",
|
|
16
16
|
"lint:staged": "eslint --",
|
|
17
17
|
"pretty": "prettier --write",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { is, MockSeries } = require('../test.js');
|
|
4
|
+
|
|
5
|
+
module.exports.test = async () => {
|
|
6
|
+
const test = got => got.name == 'test_wrap';
|
|
7
|
+
const failures_info = [
|
|
8
|
+
{
|
|
9
|
+
type: 'intermittent',
|
|
10
|
+
group: '*',
|
|
11
|
+
list: ['Server terminates connection'],
|
|
12
|
+
msg: 'Server terminates connection 421 error',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
const ts = {
|
|
16
|
+
'unit': {
|
|
17
|
+
meta: {
|
|
18
|
+
folders: ['base', 'core'],
|
|
19
|
+
expected_failures: [
|
|
20
|
+
[
|
|
21
|
+
'**',
|
|
22
|
+
[
|
|
23
|
+
[
|
|
24
|
+
'all',
|
|
25
|
+
'intermittent',
|
|
26
|
+
'*',
|
|
27
|
+
[`Server terminates connection`],
|
|
28
|
+
`Server terminates connection 421 error`,
|
|
29
|
+
],
|
|
30
|
+
],
|
|
31
|
+
],
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
'unit/base': {
|
|
36
|
+
meta: {
|
|
37
|
+
folders: ['generic'],
|
|
38
|
+
},
|
|
39
|
+
files: ['t_testo.js'],
|
|
40
|
+
},
|
|
41
|
+
'unit/base/t_testo.js': {
|
|
42
|
+
test() {},
|
|
43
|
+
},
|
|
44
|
+
'unit/base/generic': {
|
|
45
|
+
files: ['t_nahimov.js'],
|
|
46
|
+
},
|
|
47
|
+
'unit/base/generic/t_nahimov.js': {
|
|
48
|
+
test() {},
|
|
49
|
+
},
|
|
50
|
+
'unit/core': {
|
|
51
|
+
files: ['t_presto.js'],
|
|
52
|
+
},
|
|
53
|
+
'unit/core/t_presto.js': {
|
|
54
|
+
test() {},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const series = new MockSeries('', { ts });
|
|
59
|
+
const tests = await series.build({
|
|
60
|
+
patterns: [],
|
|
61
|
+
folder: 'unit',
|
|
62
|
+
virtual_folder: 'unit',
|
|
63
|
+
});
|
|
64
|
+
series.shutdown();
|
|
65
|
+
|
|
66
|
+
is(
|
|
67
|
+
tests,
|
|
68
|
+
[
|
|
69
|
+
{
|
|
70
|
+
name: 'unit/base',
|
|
71
|
+
path: 'unit/base/',
|
|
72
|
+
subtests: [
|
|
73
|
+
{
|
|
74
|
+
name: 'unit/base/t_testo.js',
|
|
75
|
+
path: 'unit/base/t_testo.js',
|
|
76
|
+
func: test,
|
|
77
|
+
failures_info,
|
|
78
|
+
webdriver: '',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'unit/base/generic',
|
|
82
|
+
path: 'unit/base/generic/',
|
|
83
|
+
subtests: [
|
|
84
|
+
{
|
|
85
|
+
name: 'unit/base/generic/t_nahimov.js',
|
|
86
|
+
path: 'unit/base/generic/t_nahimov.js',
|
|
87
|
+
func: test,
|
|
88
|
+
failures_info,
|
|
89
|
+
webdriver: '',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'unit/core',
|
|
97
|
+
path: 'unit/core/',
|
|
98
|
+
subtests: [
|
|
99
|
+
{
|
|
100
|
+
name: 'unit/core/t_presto.js',
|
|
101
|
+
path: 'unit/core/t_presto.js',
|
|
102
|
+
func: test,
|
|
103
|
+
failures_info,
|
|
104
|
+
webdriver: '',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
'build'
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { is_test_output, make_perform_function, fail } = require('../test.js');
|
|
4
|
+
|
|
5
|
+
module.exports.test = async () => {
|
|
6
|
+
let failures = [
|
|
7
|
+
[
|
|
8
|
+
'**',
|
|
9
|
+
[
|
|
10
|
+
[
|
|
11
|
+
'all',
|
|
12
|
+
'intermittent',
|
|
13
|
+
'*',
|
|
14
|
+
[`Server terminates connection`],
|
|
15
|
+
`Server terminates connection 421 error`,
|
|
16
|
+
],
|
|
17
|
+
],
|
|
18
|
+
],
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
await is_test_output(
|
|
22
|
+
make_perform_function([
|
|
23
|
+
{
|
|
24
|
+
name: 'unit',
|
|
25
|
+
subtests: [
|
|
26
|
+
{
|
|
27
|
+
name: 'unit/base',
|
|
28
|
+
subtests: [
|
|
29
|
+
{
|
|
30
|
+
name: 't_testo.js',
|
|
31
|
+
path: 't_testo.js',
|
|
32
|
+
failures,
|
|
33
|
+
func() {
|
|
34
|
+
fail('Server terminates connection');
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'unit/core',
|
|
41
|
+
subtests: [
|
|
42
|
+
{
|
|
43
|
+
name: 't_pesto.js',
|
|
44
|
+
path: 't_pesto.js',
|
|
45
|
+
failures,
|
|
46
|
+
func() {
|
|
47
|
+
fail('Server terminates connection');
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
]),
|
|
55
|
+
[
|
|
56
|
+
'\x1B[38;5;99mStarted\x1B[0m tests/',
|
|
57
|
+
'\x1B[38;5;99mStarted\x1B[0m unit',
|
|
58
|
+
'\x1B[38;5;99mStarted\x1B[0m unit/base',
|
|
59
|
+
'!Running: t_testo.js, path: t_testo.js',
|
|
60
|
+
'\x1B[33mWarning:\x1B[0m Server terminates connection',
|
|
61
|
+
'\x1B[35mIntermittent:\x1B[0m Server terminates connection 421 error',
|
|
62
|
+
'>t_testo.js has 1 intermittent(s)',
|
|
63
|
+
'>t_testo.js has 1 warnings(s)',
|
|
64
|
+
'>t_testo.js completed in',
|
|
65
|
+
'\x1B[38;5;243mCompleted\x1B[0m unit/base',
|
|
66
|
+
'\x1B[38;5;99mStarted\x1B[0m unit/core',
|
|
67
|
+
'!Running: t_pesto.js, path: t_pesto.js',
|
|
68
|
+
'\x1B[33mWarning:\x1B[0m Server terminates connection',
|
|
69
|
+
'\x1B[35mIntermittent:\x1B[0m Server terminates connection 421 error',
|
|
70
|
+
'>t_pesto.js has 1 intermittent(s)',
|
|
71
|
+
'>t_pesto.js has 1 warnings(s)',
|
|
72
|
+
'>t_pesto.js completed in',
|
|
73
|
+
'\x1B[38;5;243mCompleted\x1B[0m unit/core',
|
|
74
|
+
'\x1B[38;5;243mCompleted\x1B[0m unit',
|
|
75
|
+
'\x1B[38;5;243mCompleted\x1B[0m tests/',
|
|
76
|
+
],
|
|
77
|
+
[],
|
|
78
|
+
'global intermittents'
|
|
79
|
+
);
|
|
80
|
+
};
|
|
@@ -19,21 +19,53 @@ class Input extends AppDriver {
|
|
|
19
19
|
|
|
20
20
|
module.exports.test = do_self_tests(snippet, async session => {
|
|
21
21
|
// AppDriver: chainable
|
|
22
|
+
let expectations = session.isFirefox()
|
|
23
|
+
? [
|
|
24
|
+
`Action: Get Input`,
|
|
25
|
+
`Test: Input is shown. Selector: '#input'`,
|
|
26
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
27
|
+
`Ok: Input is shown`,
|
|
28
|
+
`Action: Input.type into Type hello`,
|
|
29
|
+
`Test: Focus. Selector: '#input'`,
|
|
30
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
31
|
+
`Ok: Focus`,
|
|
32
|
+
`Test: Focused. Selector: '#input'`,
|
|
33
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
34
|
+
`Ok: Focused`,
|
|
35
|
+
`Test: Select all text press Ctrl+A. Selector: '#input'`,
|
|
36
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
37
|
+
`Ok: Select all text press Ctrl+A`,
|
|
38
|
+
`Test: Type into Type hello. Selector: '#input'`,
|
|
39
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
40
|
+
`Ok: Type into Type hello`,
|
|
41
|
+
`Test: Check Type hello text. Expected: 'hello'. Selector: '#input'`,
|
|
42
|
+
`Ok: Check Type hello text, got: 'hello'`,
|
|
43
|
+
`Ok: Check Type hello text`,
|
|
44
|
+
]
|
|
45
|
+
: [
|
|
46
|
+
`Action: Get Input`,
|
|
47
|
+
`Test: Input is shown. Selector: '#input'`,
|
|
48
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
49
|
+
`Ok: Input is shown`,
|
|
50
|
+
`Action: Input.type into Type hello`,
|
|
51
|
+
`Test: Focus. Selector: '#input'`,
|
|
52
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
53
|
+
`Ok: Focus`,
|
|
54
|
+
`Test: Focused. Selector: '#input'`,
|
|
55
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
56
|
+
`Ok: Focused`,
|
|
57
|
+
`Test: Select all text`,
|
|
58
|
+
`Ok: Select all text`,
|
|
59
|
+
`Test: Type into Type hello. Selector: '#input'`,
|
|
60
|
+
`Ok: '#input' has to be unique, got: 1`,
|
|
61
|
+
`Ok: Type into Type hello`,
|
|
62
|
+
`Test: Check Type hello text. Expected: 'hello'. Selector: '#input'`,
|
|
63
|
+
`Ok: Check Type hello text, got: 'hello'`,
|
|
64
|
+
`Ok: Check Type hello text`,
|
|
65
|
+
];
|
|
22
66
|
await is_ok_output(
|
|
23
67
|
() => Input.get(session).type('hello'),
|
|
24
|
-
|
|
25
|
-
`Action: Get Input`,
|
|
26
|
-
`Test: Input is shown. Selector: '#input'`,
|
|
27
|
-
`Ok: '#input' has to be unique, got: 1`,
|
|
28
|
-
`Ok: Input is shown`,
|
|
29
|
-
`Action: Input.type into Type hello`,
|
|
30
|
-
`Test: Type into Type hello. Selector: '#input'`,
|
|
31
|
-
`Ok: '#input' has to be unique, got: 1`,
|
|
32
|
-
`Ok: Type into Type hello`,
|
|
33
|
-
`Test: Check Type hello text. Expected: 'hello'. Selector: '#input'`,
|
|
34
|
-
`Ok: Check Type hello text, got: 'hello'`,
|
|
35
|
-
`Ok: Check Type hello text`,
|
|
36
|
-
],
|
|
68
|
+
expectations,
|
|
37
69
|
[],
|
|
38
70
|
`AppDriver: chainable`
|
|
39
71
|
);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
do_self_tests,
|
|
5
|
+
is_ok_output,
|
|
6
|
+
} = require('./test.js');
|
|
7
|
+
|
|
8
|
+
const snippet = `
|
|
9
|
+
<html>
|
|
10
|
+
<script>
|
|
11
|
+
window.getSelection = selector => {
|
|
12
|
+
let el = document.querySelector(selector);
|
|
13
|
+
return [el.selectionStart, el.selectionEnd];
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
<body>
|
|
17
|
+
<input value='hey'>
|
|
18
|
+
<textarea>hey</textarea>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
module.exports.test = do_self_tests(snippet, async ({ driver }) => {
|
|
24
|
+
let stdout = driver.firefox
|
|
25
|
+
? [
|
|
26
|
+
`Test: select input text press Ctrl+A. Selector: 'input'`,
|
|
27
|
+
`Ok: 'input' has to be unique, got: 1`,
|
|
28
|
+
`Ok: select input text press Ctrl+A`,
|
|
29
|
+
]
|
|
30
|
+
: [`Test: select input text`, `Ok: select input text`];
|
|
31
|
+
|
|
32
|
+
// selectAll:input
|
|
33
|
+
await is_ok_output(
|
|
34
|
+
() => driver.selectAll('input', `select input text`),
|
|
35
|
+
stdout,
|
|
36
|
+
[],
|
|
37
|
+
`selectAll:input`
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
await driver.scriptRetvalIs(
|
|
41
|
+
`window.getSelection('input')`,
|
|
42
|
+
[0, 3],
|
|
43
|
+
'input text is selected'
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// selectAll:textarea
|
|
47
|
+
stdout = driver.firefox
|
|
48
|
+
? [
|
|
49
|
+
`Test: select textarea text press Ctrl+A. Selector: 'textarea'`,
|
|
50
|
+
`Ok: 'textarea' has to be unique, got: 1`,
|
|
51
|
+
`Ok: select textarea text press Ctrl+A`,
|
|
52
|
+
]
|
|
53
|
+
: [`Test: select textarea text`, `Ok: select textarea text`];
|
|
54
|
+
|
|
55
|
+
await is_ok_output(
|
|
56
|
+
() => driver.selectAll('textarea', `select textarea text`),
|
|
57
|
+
stdout,
|
|
58
|
+
[],
|
|
59
|
+
`selectAll:textarea`
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
await driver.scriptRetvalIs(
|
|
63
|
+
`window.getSelection('textarea')`,
|
|
64
|
+
[0, 3],
|
|
65
|
+
'textarea text is selected'
|
|
66
|
+
);
|
|
67
|
+
});
|
package/tests/webdriver/test.js
CHANGED
package/webdriver/app_driver.js
CHANGED
|
@@ -74,6 +74,9 @@ class AppDriver {
|
|
|
74
74
|
type(selector, value, field) {
|
|
75
75
|
return this.chain(() =>
|
|
76
76
|
this.action(`${this.uiname}.type into ${field}`)
|
|
77
|
+
.sendKeys(selector, '', `Focus`)
|
|
78
|
+
.elementFocused(selector, 'Focused')
|
|
79
|
+
.selectAll(selector, `Select all text`)
|
|
77
80
|
.sendKeys(selector, value, `Type into ${field}`)
|
|
78
81
|
.textIs(selector, value, `Check ${field} text`)
|
|
79
82
|
);
|
|
@@ -157,27 +160,6 @@ class AppDriver {
|
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
/**
|
|
161
|
-
* Control driver base.
|
|
162
|
-
*/
|
|
163
|
-
class ControlDriver extends AppDriver {
|
|
164
|
-
static get(session, selector, p) {
|
|
165
|
-
assert(selector, `No selector for ${this.name}`);
|
|
166
|
-
return this._get(
|
|
167
|
-
{
|
|
168
|
-
session,
|
|
169
|
-
selector,
|
|
170
|
-
},
|
|
171
|
-
p
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get Self() {
|
|
176
|
-
return this.selector;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
163
|
module.exports = {
|
|
181
164
|
AppDriver,
|
|
182
|
-
ControlDriver,
|
|
183
165
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { assert } = require('../core/core.js');
|
|
4
|
+
const { AppDriver } = require('./app_driver.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Control driver base.
|
|
8
|
+
*/
|
|
9
|
+
class ControlDriver extends AppDriver {
|
|
10
|
+
static get(session, selector, p) {
|
|
11
|
+
assert(selector, `No selector for ${this.name}`);
|
|
12
|
+
return this._get(
|
|
13
|
+
{
|
|
14
|
+
session,
|
|
15
|
+
selector,
|
|
16
|
+
},
|
|
17
|
+
p
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get uiname() {
|
|
22
|
+
return `${super.uiname}@selector='${this.Self}'`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get Self() {
|
|
26
|
+
return this.selector;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = {
|
|
31
|
+
ControlDriver,
|
|
32
|
+
};
|
package/webdriver/driver.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { By, Condition, Key, until } = require('selenium-webdriver');
|
|
4
4
|
|
|
5
5
|
const { test_is, test_contains, is, contains, ok } = require('../core/base.js');
|
|
6
|
-
const { assert } = require('../core/core.js');
|
|
6
|
+
const { assert, fail } = require('../core/core.js');
|
|
7
7
|
const { is_mac, stringify, toDataURL } = require('../core/util.js');
|
|
8
8
|
const { log } = require('../logging/logging.js');
|
|
9
9
|
const { getTimeout, DriverBase } = require('./driver_base.js');
|
|
@@ -316,9 +316,9 @@ class Driver extends DriverBase {
|
|
|
316
316
|
* Checks elements text whether it matches the given text.
|
|
317
317
|
*/
|
|
318
318
|
textIsAll(selector, text, msg) {
|
|
319
|
-
assert(selector, `
|
|
320
|
-
assert(text instanceof Array, `
|
|
321
|
-
assert(msg, `
|
|
319
|
+
assert(selector, `textIsAll: no selector`);
|
|
320
|
+
assert(text instanceof Array, `textIsAll: no text`);
|
|
321
|
+
assert(msg, `textIsAll: no msg`);
|
|
322
322
|
|
|
323
323
|
return this.matchTextAll({
|
|
324
324
|
selector,
|
|
@@ -789,8 +789,8 @@ class Driver extends DriverBase {
|
|
|
789
789
|
|
|
790
790
|
// ctlr+A doens't work OS X in Chrome.
|
|
791
791
|
let script = `
|
|
792
|
-
let el = document.querySelector(
|
|
793
|
-
if (el instanceof HTMLInputElement) {
|
|
792
|
+
let el = document.querySelector(\`${selector}\`);
|
|
793
|
+
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
794
794
|
el.select();
|
|
795
795
|
}
|
|
796
796
|
else {
|
|
@@ -800,7 +800,10 @@ else {
|
|
|
800
800
|
window.getSelection().addRange(r);
|
|
801
801
|
}
|
|
802
802
|
`;
|
|
803
|
-
return this.run(() => this.dvr.executeScript(script)
|
|
803
|
+
return this.run(() => this.dvr.executeScript(script).catch(e => {
|
|
804
|
+
fail(`Failed to execute selectAll script: ${script}`);
|
|
805
|
+
throw e;
|
|
806
|
+
}), msg);
|
|
804
807
|
}
|
|
805
808
|
|
|
806
809
|
/**
|