selenium-webdriver 4.0.0-alpha.3 → 4.0.0-alpha.7
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/CHANGES.md +9 -2
- package/README.md +2 -4
- package/chrome.js +19 -527
- package/chromium.js +762 -0
- package/edge.js +97 -58
- package/firefox.js +23 -5
- package/http/index.js +4 -0
- package/io/index.js +1 -1
- package/lib/actions.js +1 -1
- package/lib/atoms/get-attribute.js +1 -2
- package/lib/atoms/is-displayed.js +5 -6
- package/lib/atoms/make-atoms-module.js +17 -0
- package/lib/capabilities.js +17 -4
- package/lib/command.js +1 -0
- package/lib/http.js +8 -3
- package/lib/input.js +6 -6
- package/lib/logging.js +1 -1
- package/lib/webdriver.js +33 -3
- package/net/portprober.js +1 -1
- package/package.json +8 -9
- package/BUILD.bazel +0 -88
- package/example/chrome_android.js +0 -42
- package/example/chrome_mobile_emulation.js +0 -42
- package/example/firefox_channels.js +0 -77
- package/example/google_search.js +0 -50
- package/example/google_search_test.js +0 -72
- package/example/headless.js +0 -55
- package/example/logging.js +0 -68
- package/jasmine.json +0 -11
- package/lib/atoms/BUILD.bazel +0 -28
- package/lib/test/bootstrap_jasmine.js +0 -28
- package/lib/test/build.js +0 -156
- package/lib/test/data/actions/click.html +0 -24
- package/lib/test/data/actions/drag.html +0 -77
- package/lib/test/data/actions/record_click.html +0 -21
- package/lib/test/data/chrome/download.html +0 -2
- package/lib/test/data/firefox/webextension.xpi +0 -0
- package/lib/test/fileserver.js +0 -337
- package/lib/test/httpserver.js +0 -120
- package/lib/test/index.js +0 -87
- package/lib/test/resources.js +0 -40
- package/test/actions_test.js +0 -206
- package/test/builder_test.js +0 -106
- package/test/chrome/devtools_test.js +0 -93
- package/test/chrome/options_test.js +0 -121
- package/test/chrome/service_test.js +0 -45
- package/test/cookie_test.js +0 -210
- package/test/element_finding_test.js +0 -431
- package/test/execute_script_test.js +0 -355
- package/test/fingerprint_test.js +0 -63
- package/test/firefox_test.js +0 -233
- package/test/frame_test.js +0 -45
- package/test/http/http_test.js +0 -229
- package/test/http/util_test.js +0 -178
- package/test/io/io_test.js +0 -364
- package/test/io/zip_test.js +0 -126
- package/test/lib/by_test.js +0 -160
- package/test/lib/capabilities_test.js +0 -129
- package/test/lib/error_test.js +0 -333
- package/test/lib/http_test.js +0 -576
- package/test/lib/input_test.js +0 -1379
- package/test/lib/logging_test.js +0 -272
- package/test/lib/promise_test.js +0 -674
- package/test/lib/testutil.js +0 -90
- package/test/lib/until_test.js +0 -478
- package/test/lib/webdriver_test.js +0 -1692
- package/test/logging_test.js +0 -160
- package/test/net/index_test.js +0 -60
- package/test/net/portprober_test.js +0 -128
- package/test/page_loading_test.js +0 -156
- package/test/proxy_test.js +0 -167
- package/test/rect_test.js +0 -51
- package/test/remote_test.js +0 -98
- package/test/safari_test.js +0 -44
- package/test/stale_element_test.js +0 -60
- package/test/upload_test.js +0 -78
- package/test/window_test.js +0 -168
- package/testing/index.js +0 -498
- package/tools/init_jasmine.js +0 -7
package/lib/test/httpserver.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
var assert = require('assert'),
|
|
21
|
-
http = require('http'),
|
|
22
|
-
url = require('url');
|
|
23
|
-
|
|
24
|
-
var net = require('../../net'),
|
|
25
|
-
portprober = require('../../net/portprober'),
|
|
26
|
-
promise = require('../..').promise;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Encapsulates a simple HTTP server for testing. The {@code onrequest}
|
|
32
|
-
* function should be overridden to define request handling behavior.
|
|
33
|
-
* @param {function(!http.ServerRequest, !http.ServerResponse)} requestHandler
|
|
34
|
-
* The request handler for the server.
|
|
35
|
-
* @constructor
|
|
36
|
-
*/
|
|
37
|
-
var Server = function(requestHandler) {
|
|
38
|
-
var server = http.createServer(function(req, res) {
|
|
39
|
-
requestHandler(req, res);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
server.on('connection', function(stream) {
|
|
43
|
-
stream.setTimeout(4000);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
/** @typedef {{port: number, address: string, family: string}} */
|
|
47
|
-
var Host;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Starts the server on the given port. If no port, or 0, is provided,
|
|
51
|
-
* the server will be started on a random port.
|
|
52
|
-
* @param {number=} opt_port The port to start on.
|
|
53
|
-
* @return {!Promise<Host>} A promise that will resolve
|
|
54
|
-
* with the server host when it has fully started.
|
|
55
|
-
*/
|
|
56
|
-
this.start = function(opt_port) {
|
|
57
|
-
assert(typeof opt_port !== 'function',
|
|
58
|
-
"start invoked with function, not port (mocha callback)?");
|
|
59
|
-
var port = opt_port || portprober.findFreePort('localhost');
|
|
60
|
-
return Promise.resolve(port).then(port => {
|
|
61
|
-
return promise.checkedNodeCall(
|
|
62
|
-
server.listen.bind(server, port, 'localhost'));
|
|
63
|
-
}).then(function() {
|
|
64
|
-
return server.address();
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Stops the server.
|
|
70
|
-
* @return {!Promise} A promise that will resolve when the
|
|
71
|
-
* server has closed all connections.
|
|
72
|
-
*/
|
|
73
|
-
this.stop = function() {
|
|
74
|
-
return new Promise(resolve => server.close(resolve));
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @return {Host} This server's host info.
|
|
79
|
-
* @throws {Error} If the server is not running.
|
|
80
|
-
*/
|
|
81
|
-
this.address = function() {
|
|
82
|
-
var addr = server.address();
|
|
83
|
-
if (!addr) {
|
|
84
|
-
throw Error('There server is not running!');
|
|
85
|
-
}
|
|
86
|
-
return addr;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* return {string} The host:port of this server.
|
|
91
|
-
* @throws {Error} If the server is not running.
|
|
92
|
-
*/
|
|
93
|
-
this.host = function() {
|
|
94
|
-
return net.getLoopbackAddress() + ':' +
|
|
95
|
-
this.address().port;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Formats a URL for this server.
|
|
100
|
-
* @param {string=} opt_pathname The desired pathname on the server.
|
|
101
|
-
* @return {string} The formatted URL.
|
|
102
|
-
* @throws {Error} If the server is not running.
|
|
103
|
-
*/
|
|
104
|
-
this.url = function(opt_pathname) {
|
|
105
|
-
var addr = this.address();
|
|
106
|
-
var pathname = opt_pathname || '';
|
|
107
|
-
return url.format({
|
|
108
|
-
protocol: 'http',
|
|
109
|
-
hostname: net.getLoopbackAddress(),
|
|
110
|
-
port: addr.port,
|
|
111
|
-
pathname: pathname
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// PUBLIC API
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
exports.Server = Server;
|
package/lib/test/index.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
|
|
22
|
-
const build = require('./build');
|
|
23
|
-
const fileserver = require('./fileserver');
|
|
24
|
-
const firefox = require('../../firefox');
|
|
25
|
-
const logging = require('../../lib/logging');
|
|
26
|
-
const remote = require('../../remote');
|
|
27
|
-
const safari = require('../../safari');
|
|
28
|
-
const testing = require('../../testing');
|
|
29
|
-
const webdriver = require('../../');
|
|
30
|
-
|
|
31
|
-
const NO_BUILD = /^1|true$/i.test(process.env['SELENIUM_NO_BUILD']);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {function(!testing.Environment)} fn The top level suite function.
|
|
36
|
-
* @param {testing.SuiteOptions=} options Suite specific options.
|
|
37
|
-
*/
|
|
38
|
-
function suite(fn, options = undefined) {
|
|
39
|
-
testing.suite(function(env) {
|
|
40
|
-
before(function() {
|
|
41
|
-
if (false && !NO_BUILD) {
|
|
42
|
-
return build.of(
|
|
43
|
-
'//javascript/atoms/fragments:is-displayed',
|
|
44
|
-
'//javascript/webdriver/atoms:get-attribute')
|
|
45
|
-
.onlyOnce().go();
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
fn(env);
|
|
50
|
-
}, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// GLOBAL TEST SETUP
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
process.on('unhandledRejection', (reason) => {
|
|
58
|
-
console.error('Unhandled promise rejection:', reason);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (/^1|true$/i.test(process.env['SELENIUM_VERBOSE'])) {
|
|
63
|
-
logging.installConsoleHandler();
|
|
64
|
-
logging.getLogger('webdriver.http').setLevel(logging.Level.ALL);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
testing.init();
|
|
68
|
-
|
|
69
|
-
before(function() {
|
|
70
|
-
// Do not pass register fileserver.start directly with testing.before,
|
|
71
|
-
// as start takes an optional port, which before assumes is an async
|
|
72
|
-
// callback.
|
|
73
|
-
return fileserver.start();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
after(function() {
|
|
77
|
-
return fileserver.stop();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// PUBLIC API
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
exports.suite = suite;
|
|
85
|
-
exports.ignore = testing.ignore;
|
|
86
|
-
exports.Pages = fileserver.Pages;
|
|
87
|
-
exports.whereIs = fileserver.whereIs;
|
package/lib/test/resources.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const fs = require('fs');
|
|
21
|
-
const path = require('path');
|
|
22
|
-
const {projectRoot} = require('./build');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// PUBLIC API
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Locates a test resource.
|
|
30
|
-
* @param {string} filePath The file to locate from the root of the project.
|
|
31
|
-
* @return {string} The full path for the file, if it exists.
|
|
32
|
-
* @throws {Error} If the file does not exist.
|
|
33
|
-
*/
|
|
34
|
-
exports.locate = function(filePath) {
|
|
35
|
-
var fullPath = path.normalize(path.join(projectRoot(), filePath));
|
|
36
|
-
if (!fs.existsSync(fullPath)) {
|
|
37
|
-
throw Error('File does not exist: ' + filePath);
|
|
38
|
-
}
|
|
39
|
-
return fullPath;
|
|
40
|
-
};
|
package/test/actions_test.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
|
|
22
|
-
const chrome = require('../chrome');
|
|
23
|
-
const error = require('../lib/error');
|
|
24
|
-
const fileServer = require('../lib/test/fileserver');
|
|
25
|
-
const firefox = require('../firefox');
|
|
26
|
-
const test = require('../lib/test');
|
|
27
|
-
const {Key, Origin} = require('../lib/input');
|
|
28
|
-
const {Browser, By, until} = require('..');
|
|
29
|
-
|
|
30
|
-
test.suite(function(env) {
|
|
31
|
-
describe('WebDriver.actions()', function() {
|
|
32
|
-
let driver;
|
|
33
|
-
|
|
34
|
-
before(async function() {
|
|
35
|
-
driver = await env.builder().build();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
afterEach(async function() {
|
|
39
|
-
try {
|
|
40
|
-
await driver.actions().clear();
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (e instanceof error.UnsupportedOperationError
|
|
43
|
-
|| e instanceof error.UnknownCommandError) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
throw e;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
after(function() {
|
|
51
|
-
return driver.quit();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('click(element)', async function() {
|
|
55
|
-
await driver.get(fileServer.whereIs('/data/actions/click.html'));
|
|
56
|
-
|
|
57
|
-
let box = await driver.findElement(By.id('box'));
|
|
58
|
-
assert.equal(await box.getAttribute('class'), '');
|
|
59
|
-
|
|
60
|
-
await driver.actions().click(box).perform();
|
|
61
|
-
assert.equal(await box.getAttribute('class'), 'green');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('click(element) clicks in center of element', async function() {
|
|
65
|
-
await driver.get(fileServer.whereIs('/data/actions/record_click.html'));
|
|
66
|
-
|
|
67
|
-
const div = await driver.findElement(By.css('div'));
|
|
68
|
-
const rect = await div.getRect();
|
|
69
|
-
assert.deepEqual(rect, {width: 500, height: 500, x: 0, y: 0});
|
|
70
|
-
|
|
71
|
-
await driver.actions().click(div).perform();
|
|
72
|
-
|
|
73
|
-
const clicks = await driver.executeScript('return clicks');
|
|
74
|
-
assert.deepEqual(clicks, [[250, 250]]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('can move relative to element center', async function() {
|
|
78
|
-
await driver.get(fileServer.whereIs('/data/actions/record_click.html'));
|
|
79
|
-
|
|
80
|
-
const div = await driver.findElement(By.css('div'));
|
|
81
|
-
const rect = await div.getRect();
|
|
82
|
-
assert.deepEqual(rect, {width: 500, height: 500, x: 0, y: 0});
|
|
83
|
-
|
|
84
|
-
await driver.actions()
|
|
85
|
-
.move({x: 10, y: 10, origin: div})
|
|
86
|
-
.click()
|
|
87
|
-
.perform();
|
|
88
|
-
|
|
89
|
-
const clicks = await driver.executeScript('return clicks');
|
|
90
|
-
assert.deepEqual(clicks, [[260, 260]]);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test.ignore(env.browsers(Browser.SAFARI)).
|
|
94
|
-
it('doubleClick(element)', async function() {
|
|
95
|
-
await driver.get(fileServer.whereIs('/data/actions/click.html'));
|
|
96
|
-
|
|
97
|
-
let box = await driver.findElement(By.id('box'));
|
|
98
|
-
assert.equal(await box.getAttribute('class'), '');
|
|
99
|
-
|
|
100
|
-
await driver.actions().doubleClick(box).perform();
|
|
101
|
-
assert.equal(await box.getAttribute('class'), 'blue');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// For some reason for Chrome 75 we need to wrap this test in an extra
|
|
105
|
-
// describe for the afterEach hook above to properly clear action sequences.
|
|
106
|
-
// This appears to be a quirk of the timing around mocha tests and not
|
|
107
|
-
// necessarily a bug in the chromedriver.
|
|
108
|
-
// TODO(jleyba): dig into this more so we can remove this hack.
|
|
109
|
-
describe('dragAndDrop()', function() {
|
|
110
|
-
it('', async function() {
|
|
111
|
-
await driver.get(fileServer.whereIs('/data/actions/drag.html'));
|
|
112
|
-
|
|
113
|
-
let slide = await driver.findElement(By.id('slide'));
|
|
114
|
-
assert.equal(await slide.getCssValue('left'), '0px');
|
|
115
|
-
assert.equal(await slide.getCssValue('top'), '0px');
|
|
116
|
-
|
|
117
|
-
let br = await driver.findElement(By.id('BR'));
|
|
118
|
-
await driver.actions().dragAndDrop(slide, br).perform();
|
|
119
|
-
assert.equal(await slide.getCssValue('left'), '206px');
|
|
120
|
-
assert.equal(await slide.getCssValue('top'), '206px');
|
|
121
|
-
|
|
122
|
-
let tr = await driver.findElement(By.id('TR'));
|
|
123
|
-
await driver.actions().dragAndDrop(slide, tr).perform();
|
|
124
|
-
assert.equal(await slide.getCssValue('left'), '206px');
|
|
125
|
-
assert.equal(await slide.getCssValue('top'), '1px');
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('move()', async function() {
|
|
130
|
-
await driver.get(fileServer.whereIs('/data/actions/drag.html'));
|
|
131
|
-
|
|
132
|
-
let slide = await driver.findElement(By.id('slide'));
|
|
133
|
-
assert.equal(await slide.getCssValue('left'), '0px');
|
|
134
|
-
assert.equal(await slide.getCssValue('top'), '0px');
|
|
135
|
-
|
|
136
|
-
await driver.actions()
|
|
137
|
-
.move({origin: slide})
|
|
138
|
-
.press()
|
|
139
|
-
.move({x: 100, y: 100, origin: Origin.POINTER})
|
|
140
|
-
.release()
|
|
141
|
-
.perform();
|
|
142
|
-
assert.equal(await slide.getCssValue('left'), '101px');
|
|
143
|
-
assert.equal(await slide.getCssValue('top'), '101px');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('can move to and click element in an iframe', async function() {
|
|
147
|
-
await driver.get(fileServer.whereIs('click_tests/click_in_iframe.html'));
|
|
148
|
-
|
|
149
|
-
await driver.wait(until.elementLocated(By.id('ifr')), 5000)
|
|
150
|
-
.then(frame => driver.switchTo().frame(frame));
|
|
151
|
-
|
|
152
|
-
let link = await driver.findElement(By.id('link'));
|
|
153
|
-
|
|
154
|
-
await driver.actions().click(link).perform();
|
|
155
|
-
await driver.switchTo().defaultContent();
|
|
156
|
-
return driver.wait(until.titleIs('Submitted Successfully!'), 5000);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('can send keys to focused element', async function() {
|
|
160
|
-
await driver.get(test.Pages.formPage);
|
|
161
|
-
|
|
162
|
-
let el = await driver.findElement(By.id('email'));
|
|
163
|
-
assert.equal(await el.getAttribute('value'), '');
|
|
164
|
-
|
|
165
|
-
await driver.executeScript('arguments[0].focus()', el);
|
|
166
|
-
|
|
167
|
-
await driver.actions().sendKeys('foobar').perform();
|
|
168
|
-
|
|
169
|
-
assert.equal(await el.getAttribute('value'), 'foobar');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('can send keys to focused element (with modifiers)', async function() {
|
|
173
|
-
await driver.get(test.Pages.formPage);
|
|
174
|
-
|
|
175
|
-
let el = await driver.findElement(By.id('email'));
|
|
176
|
-
assert.equal(await el.getAttribute('value'), '');
|
|
177
|
-
|
|
178
|
-
await driver.executeScript('arguments[0].focus()', el);
|
|
179
|
-
|
|
180
|
-
await driver.actions()
|
|
181
|
-
.sendKeys('fo')
|
|
182
|
-
.keyDown(Key.SHIFT)
|
|
183
|
-
.sendKeys('OB')
|
|
184
|
-
.keyUp(Key.SHIFT)
|
|
185
|
-
.sendKeys('ar')
|
|
186
|
-
.perform();
|
|
187
|
-
|
|
188
|
-
assert.equal(await el.getAttribute('value'), 'foOBar');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('can interact with simple form elements', async function() {
|
|
192
|
-
await driver.get(test.Pages.formPage);
|
|
193
|
-
|
|
194
|
-
let el = await driver.findElement(By.id('email'));
|
|
195
|
-
assert.equal(await el.getAttribute('value'), '');
|
|
196
|
-
|
|
197
|
-
await driver.actions()
|
|
198
|
-
.click(el)
|
|
199
|
-
.sendKeys('foobar')
|
|
200
|
-
.perform();
|
|
201
|
-
|
|
202
|
-
assert.equal(await el.getAttribute('value'), 'foobar');
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
package/test/builder_test.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
|
|
22
|
-
const chrome = require('../chrome');
|
|
23
|
-
const edge = require('../edge');
|
|
24
|
-
const error = require('../lib/error');
|
|
25
|
-
const firefox = require('../firefox');
|
|
26
|
-
const ie = require('../ie');
|
|
27
|
-
const safari = require('../safari');
|
|
28
|
-
const test = require('../lib/test');
|
|
29
|
-
const {Browser} = require('../lib/capabilities');
|
|
30
|
-
const {Pages} = require('../lib/test');
|
|
31
|
-
const {Builder, Capabilities, WebDriver} = require('..');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
test.suite(function(env) {
|
|
35
|
-
const browsers = (...args) => env.browsers(...args);
|
|
36
|
-
|
|
37
|
-
const BROWSER_MAP = new Map([
|
|
38
|
-
[Browser.CHROME, chrome.Driver],
|
|
39
|
-
[Browser.EDGE, edge.Driver],
|
|
40
|
-
[Browser.FIREFOX, firefox.Driver],
|
|
41
|
-
[Browser.INTERNET_EXPLORER, ie.Driver],
|
|
42
|
-
[Browser.SAFARI, safari.Driver],
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
if (BROWSER_MAP.has(env.browser.name)) {
|
|
46
|
-
describe('builder creates thenable driver instances', function() {
|
|
47
|
-
let driver;
|
|
48
|
-
|
|
49
|
-
after(() => driver && driver.quit());
|
|
50
|
-
|
|
51
|
-
it(env.browser.name, function() {
|
|
52
|
-
driver = env.builder().build();
|
|
53
|
-
|
|
54
|
-
const want = BROWSER_MAP.get(env.browser.name);
|
|
55
|
-
assert.ok(
|
|
56
|
-
driver instanceof want,
|
|
57
|
-
`want ${want.name}, but got ${driver.name}`);
|
|
58
|
-
assert.equal(typeof driver.then, 'function');
|
|
59
|
-
|
|
60
|
-
return driver
|
|
61
|
-
.then(
|
|
62
|
-
d =>
|
|
63
|
-
assert.ok(
|
|
64
|
-
d instanceof want,
|
|
65
|
-
`want ${want.name}, but got ${d.name}`))
|
|
66
|
-
// Load something so the safari driver doesn't crash from starting and
|
|
67
|
-
// stopping in short time.
|
|
68
|
-
.then(() => driver.get(Pages.echoPage));
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
class OptionsTest {
|
|
74
|
-
constructor(ctor, key) {
|
|
75
|
-
this.ctor = ctor;
|
|
76
|
-
this.key = key;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Builder', function() {
|
|
83
|
-
describe('catches incorrect use of browser options class', function() {
|
|
84
|
-
function test(key, options) {
|
|
85
|
-
it(key, async function() {
|
|
86
|
-
let builder = new Builder()
|
|
87
|
-
.withCapabilities(new Capabilities()
|
|
88
|
-
.set('browserName', 'fake-browser-should-not-try-to-start')
|
|
89
|
-
.set(key, new options()));
|
|
90
|
-
try {
|
|
91
|
-
let driver = await builder.build();
|
|
92
|
-
await driver.quit();
|
|
93
|
-
return Promise.reject(Error('should have failed'));
|
|
94
|
-
} catch (ex) {
|
|
95
|
-
if (!(ex instanceof error.InvalidArgumentError)) {
|
|
96
|
-
throw ex;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
test('chromeOptions', chrome.Options);
|
|
103
|
-
test('moz:firefoxOptions', firefox.Options);
|
|
104
|
-
test('safari.options', safari.Options);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
const fs = require('fs');
|
|
22
|
-
const path = require('path');
|
|
23
|
-
|
|
24
|
-
const chrome = require('../../chrome');
|
|
25
|
-
const error = require('../../lib/error');
|
|
26
|
-
const fileServer = require('../../lib/test/fileserver');
|
|
27
|
-
const io = require('../../io');
|
|
28
|
-
const test = require('../../lib/test');
|
|
29
|
-
const webdriver = require('../..');
|
|
30
|
-
|
|
31
|
-
test.suite(function(env) {
|
|
32
|
-
let driver;
|
|
33
|
-
|
|
34
|
-
before(async function() {
|
|
35
|
-
driver = await env.builder()
|
|
36
|
-
.setChromeOptions(new chrome.Options().headless())
|
|
37
|
-
.build();
|
|
38
|
-
});
|
|
39
|
-
after(() => driver.quit());
|
|
40
|
-
|
|
41
|
-
it('can send commands to devtools', async function() {
|
|
42
|
-
await driver.get(test.Pages.ajaxyPage);
|
|
43
|
-
assert.equal(await driver.getCurrentUrl(), test.Pages.ajaxyPage);
|
|
44
|
-
|
|
45
|
-
await driver.sendDevToolsCommand(
|
|
46
|
-
'Page.navigate', {url: test.Pages.echoPage});
|
|
47
|
-
assert.equal(await driver.getCurrentUrl(), test.Pages.echoPage);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('setDownloadPath', function() {
|
|
51
|
-
it('can enable downloads in headless mode', async function() {
|
|
52
|
-
const dir = await io.tmpDir();
|
|
53
|
-
await driver.setDownloadPath(dir);
|
|
54
|
-
|
|
55
|
-
const url = fileServer.whereIs('/data/firefox/webextension.xpi');
|
|
56
|
-
await driver.get(`data:text/html,<!DOCTYPE html>
|
|
57
|
-
<div><a download="" href="${url}">Go!</a></div>`);
|
|
58
|
-
|
|
59
|
-
await driver.findElement({css: 'a'}).click();
|
|
60
|
-
|
|
61
|
-
const downloadPath = path.join(dir, 'webextension.xpi');
|
|
62
|
-
await driver.wait(() => io.exists(downloadPath), 5000);
|
|
63
|
-
|
|
64
|
-
const goldenPath =
|
|
65
|
-
path.join(__dirname, '../../lib/test/data/firefox/webextension.xpi');
|
|
66
|
-
assert.equal(
|
|
67
|
-
fs.readFileSync(downloadPath, 'binary'),
|
|
68
|
-
fs.readFileSync(goldenPath, 'binary'));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('throws if path is not a directory', async function() {
|
|
72
|
-
await assertInvalidArgumentError(() => driver.setDownloadPath());
|
|
73
|
-
await assertInvalidArgumentError(() => driver.setDownloadPath(null));
|
|
74
|
-
await assertInvalidArgumentError(() => driver.setDownloadPath(''));
|
|
75
|
-
await assertInvalidArgumentError(() => driver.setDownloadPath(1234));
|
|
76
|
-
|
|
77
|
-
const file = await io.tmpFile();
|
|
78
|
-
await assertInvalidArgumentError(() => driver.setDownloadPath(file));
|
|
79
|
-
|
|
80
|
-
async function assertInvalidArgumentError(fn) {
|
|
81
|
-
try {
|
|
82
|
-
await fn();
|
|
83
|
-
return Promise.reject(Error('should have failed'));
|
|
84
|
-
} catch (err) {
|
|
85
|
-
if (err instanceof error.InvalidArgumentError) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
throw err;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}, {browsers: ['chrome']});
|