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/webdriver.js
CHANGED
|
@@ -42,6 +42,7 @@ const W3C_CAPABILITY_NAMES = new Set([
|
|
|
42
42
|
'proxy',
|
|
43
43
|
'setWindowRect',
|
|
44
44
|
'timeouts',
|
|
45
|
+
'strictFileInteractability',
|
|
45
46
|
'unhandledPromptBehavior',
|
|
46
47
|
]);
|
|
47
48
|
|
|
@@ -1110,7 +1111,7 @@ class Options {
|
|
|
1110
1111
|
* invalid.
|
|
1111
1112
|
* @throws {TypeError} if `spec` is not a cookie object.
|
|
1112
1113
|
*/
|
|
1113
|
-
addCookie({name, value, path, domain, secure, httpOnly, expiry}) {
|
|
1114
|
+
addCookie({name, value, path, domain, secure, httpOnly, expiry, sameSite}) {
|
|
1114
1115
|
// We do not allow '=' or ';' in the name.
|
|
1115
1116
|
if (/[;=]/.test(name)) {
|
|
1116
1117
|
throw new error.InvalidArgumentError(
|
|
@@ -1130,6 +1131,11 @@ class Options {
|
|
|
1130
1131
|
expiry = Math.floor(date.getTime() / 1000);
|
|
1131
1132
|
}
|
|
1132
1133
|
|
|
1134
|
+
if(sameSite && sameSite !== 'Strict' && sameSite !== 'Lax') {
|
|
1135
|
+
throw new error.InvalidArgumentError(
|
|
1136
|
+
`Invalid sameSite cookie value '${sameSite}'. It should be either "Lax" (or) "Strict" `);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1133
1139
|
return this.driver_.execute(
|
|
1134
1140
|
new command.Command(command.Name.ADD_COOKIE).
|
|
1135
1141
|
setParameter('cookie', {
|
|
@@ -1139,7 +1145,8 @@ class Options {
|
|
|
1139
1145
|
'domain': domain,
|
|
1140
1146
|
'secure': !!secure,
|
|
1141
1147
|
'httpOnly': !!httpOnly,
|
|
1142
|
-
'expiry': expiry
|
|
1148
|
+
'expiry': expiry,
|
|
1149
|
+
'sameSite': sameSite
|
|
1143
1150
|
}));
|
|
1144
1151
|
}
|
|
1145
1152
|
|
|
@@ -1187,7 +1194,8 @@ class Options {
|
|
|
1187
1194
|
*
|
|
1188
1195
|
* @param {string} name The name of the cookie to retrieve.
|
|
1189
1196
|
* @return {!Promise<?Options.Cookie>} A promise that will be resolved
|
|
1190
|
-
* with the named cookie
|
|
1197
|
+
* with the named cookie
|
|
1198
|
+
* @throws {error.NoSuchCookieError} if there is no such cookie.
|
|
1191
1199
|
*/
|
|
1192
1200
|
async getCookie(name) {
|
|
1193
1201
|
try {
|
|
@@ -1397,6 +1405,17 @@ Options.Cookie.prototype.httpOnly;
|
|
|
1397
1405
|
Options.Cookie.prototype.expiry;
|
|
1398
1406
|
|
|
1399
1407
|
|
|
1408
|
+
/**
|
|
1409
|
+
* When the cookie applies to a SameSite policy.
|
|
1410
|
+
*
|
|
1411
|
+
* When {@linkplain Options#addCookie() adding a cookie}, this may be specified
|
|
1412
|
+
* as a {@link string} object which is either 'Lax' or 'Strict'.
|
|
1413
|
+
*
|
|
1414
|
+
*
|
|
1415
|
+
* @type {(!Date|number|undefined)}
|
|
1416
|
+
*/
|
|
1417
|
+
Options.Cookie.prototype.sameSite;
|
|
1418
|
+
|
|
1400
1419
|
/**
|
|
1401
1420
|
* An interface for managing the current window.
|
|
1402
1421
|
*
|
|
@@ -2099,6 +2118,17 @@ class WebElement {
|
|
|
2099
2118
|
setParameter('name', attributeName));
|
|
2100
2119
|
}
|
|
2101
2120
|
|
|
2121
|
+
/**
|
|
2122
|
+
* Get the given property of the referenced web element
|
|
2123
|
+
* @param {string} propertyName The name of the attribute to query.
|
|
2124
|
+
* @return {!Promise<string>} A promise that will be
|
|
2125
|
+
* resolved with the element's property value
|
|
2126
|
+
*/
|
|
2127
|
+
getProperty(propertyName) {
|
|
2128
|
+
return this.execute_(
|
|
2129
|
+
new command.Command(command.Name.GET_ELEMENT_PROPERTY).setParameter('name', propertyName));
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2102
2132
|
/**
|
|
2103
2133
|
* Get the visible (i.e. not hidden by CSS) innerText of this element,
|
|
2104
2134
|
* including sub-elements, without any leading or trailing whitespace.
|
package/net/portprober.js
CHANGED
|
@@ -149,7 +149,7 @@ async function findWindowsPortRange() {
|
|
|
149
149
|
function isFree(port, opt_host) {
|
|
150
150
|
return new Promise((resolve, reject) => {
|
|
151
151
|
let server = net.createServer().on('error', function(e) {
|
|
152
|
-
if (e.code === 'EADDRINUSE') {
|
|
152
|
+
if (e.code === 'EADDRINUSE' || e.code === 'EACCES') {
|
|
153
153
|
resolve(false);
|
|
154
154
|
} else {
|
|
155
155
|
reject(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "selenium-webdriver",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.7",
|
|
4
4
|
"description": "The official WebDriver JavaScript bindings from the Selenium project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -23,18 +23,17 @@
|
|
|
23
23
|
"node": ">= 10.15.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"jszip": "^3.
|
|
27
|
-
"rimraf": "^2.
|
|
28
|
-
"tmp": "0.0.30"
|
|
29
|
-
"xml2js": "^0.4.19"
|
|
26
|
+
"jszip": "^3.2.2",
|
|
27
|
+
"rimraf": "^2.7.1",
|
|
28
|
+
"tmp": "0.0.30"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"express": "^4.
|
|
33
|
-
"jasmine": "^3.
|
|
31
|
+
"express": "^4.17.1",
|
|
32
|
+
"jasmine": "^3.5.0",
|
|
34
33
|
"mocha": "^5.2.0",
|
|
35
|
-
"multer": "^1.4.
|
|
34
|
+
"multer": "^1.4.2",
|
|
36
35
|
"serve-index": "^1.9.1",
|
|
37
|
-
"sinon": "^7.
|
|
36
|
+
"sinon": "^7.5.0"
|
|
38
37
|
},
|
|
39
38
|
"scripts": {
|
|
40
39
|
"test": "mocha -t 600000 --recursive test",
|
package/BUILD.bazel
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "npm_package")
|
|
2
|
-
load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test")
|
|
3
|
-
|
|
4
|
-
SRC_FILES = [
|
|
5
|
-
"CHANGES.md",
|
|
6
|
-
"README.md",
|
|
7
|
-
"package.json",
|
|
8
|
-
] + glob([
|
|
9
|
-
"*.js",
|
|
10
|
-
"example/*.js",
|
|
11
|
-
"http/*.js",
|
|
12
|
-
"io/*.js",
|
|
13
|
-
"lib/*.js",
|
|
14
|
-
"net/*.js",
|
|
15
|
-
"remote/*.js",
|
|
16
|
-
"testing/*.js",
|
|
17
|
-
])
|
|
18
|
-
|
|
19
|
-
npm_package(
|
|
20
|
-
name = "selenium-webdriver",
|
|
21
|
-
srcs = SRC_FILES,
|
|
22
|
-
deps = [
|
|
23
|
-
":license",
|
|
24
|
-
"//javascript/node/selenium-webdriver/lib/atoms:get_attribute",
|
|
25
|
-
"//javascript/node/selenium-webdriver/lib/atoms:is_displayed",
|
|
26
|
-
],
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
TEST_FILES = glob(["test/**/*_test.js"])
|
|
30
|
-
|
|
31
|
-
TEST_DATA = SRC_FILES + glob(
|
|
32
|
-
[
|
|
33
|
-
"lib/test/**",
|
|
34
|
-
"test/**",
|
|
35
|
-
],
|
|
36
|
-
exclude = TEST_FILES,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
nodejs_binary(
|
|
40
|
-
name = "fileserver",
|
|
41
|
-
data = TEST_DATA + [
|
|
42
|
-
"//common/src/web",
|
|
43
|
-
"@npm//express",
|
|
44
|
-
"@npm//multer",
|
|
45
|
-
"@npm//serve-index",
|
|
46
|
-
"@npm//tmp",
|
|
47
|
-
"@npm//jszip",
|
|
48
|
-
"@npm//rimraf",
|
|
49
|
-
"//javascript/node/selenium-webdriver/lib/atoms:get_attribute",
|
|
50
|
-
"//javascript/node/selenium-webdriver/lib/atoms:is_displayed",
|
|
51
|
-
],
|
|
52
|
-
entry_point = "selenium/javascript/node/selenium-webdriver/lib/test/fileserver.js",
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
jasmine_node_test(
|
|
56
|
-
name = "tests",
|
|
57
|
-
srcs = TEST_FILES,
|
|
58
|
-
bootstrap = ["selenium/javascript/node/selenium-webdriver/tools/init_jasmine.js"],
|
|
59
|
-
data = TEST_DATA + [
|
|
60
|
-
"tools/init_jasmine.js",
|
|
61
|
-
"//common/src/web",
|
|
62
|
-
"@npm//express",
|
|
63
|
-
"@npm//multer",
|
|
64
|
-
"@npm//serve-index",
|
|
65
|
-
"@npm//jszip",
|
|
66
|
-
"@npm//rimraf",
|
|
67
|
-
"@npm//tmp",
|
|
68
|
-
"@npm//sinon",
|
|
69
|
-
"@npm//xml2js",
|
|
70
|
-
],
|
|
71
|
-
local = True,
|
|
72
|
-
deps = [
|
|
73
|
-
"//javascript/node/selenium-webdriver/lib/atoms:get_attribute",
|
|
74
|
-
"//javascript/node/selenium-webdriver/lib/atoms:is_displayed",
|
|
75
|
-
"@npm//jasmine",
|
|
76
|
-
],
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
# npm_package does not pick up filegroup sources.
|
|
80
|
-
genrule(
|
|
81
|
-
name = "license",
|
|
82
|
-
srcs = ["//:license"],
|
|
83
|
-
outs = [
|
|
84
|
-
"LICENSE",
|
|
85
|
-
"NOTICE",
|
|
86
|
-
],
|
|
87
|
-
cmd = "cp $(locations //:license) $(@D)",
|
|
88
|
-
)
|
|
@@ -1,42 +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
|
-
/**
|
|
19
|
-
* @fileoverview A basic example of working with Chrome on Android. Before
|
|
20
|
-
* running this example, you must start adb and connect a device (or start an
|
|
21
|
-
* AVD).
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
'use strict';
|
|
25
|
-
|
|
26
|
-
const {Builder, By, Key, until} = require('..');
|
|
27
|
-
const {Options} = require('../chrome');
|
|
28
|
-
|
|
29
|
-
(async function() {
|
|
30
|
-
let driver;
|
|
31
|
-
try {
|
|
32
|
-
driver = await new Builder()
|
|
33
|
-
.forBrowser('chrome')
|
|
34
|
-
.setChromeOptions(new Options().androidChrome())
|
|
35
|
-
.build();
|
|
36
|
-
await driver.get('http://www.google.com/ncr');
|
|
37
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
38
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
39
|
-
} finally {
|
|
40
|
-
await driver && driver.quit();
|
|
41
|
-
}
|
|
42
|
-
})().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|
|
@@ -1,42 +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
|
-
/**
|
|
19
|
-
* @fileoverview This is an example of emulating a mobile device using the
|
|
20
|
-
* ChromeDriver.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict';
|
|
24
|
-
|
|
25
|
-
const {Builder, By, Key, until} = require('..');
|
|
26
|
-
const {Options} = require('../chrome');
|
|
27
|
-
|
|
28
|
-
(async function() {
|
|
29
|
-
let driver;
|
|
30
|
-
try {
|
|
31
|
-
driver = await new Builder()
|
|
32
|
-
.forBrowser('chrome')
|
|
33
|
-
.setChromeOptions(
|
|
34
|
-
new Options().setMobileEmulation({deviceName: 'Nexus 5X'}))
|
|
35
|
-
.build();
|
|
36
|
-
await driver.get('http://www.google.com/ncr');
|
|
37
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
38
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
39
|
-
} finally {
|
|
40
|
-
await driver && driver.quit();
|
|
41
|
-
}
|
|
42
|
-
})().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|
|
@@ -1,77 +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
|
-
/**
|
|
19
|
-
* @fileoverview This is an example of working with the different Firefox
|
|
20
|
-
* release channels. Before running this example, you will need to have
|
|
21
|
-
* installed Firefox's release, nightly, and developer editions:
|
|
22
|
-
*
|
|
23
|
-
* - https://www.mozilla.org/en-US/firefox/channel/desktop/#aurora
|
|
24
|
-
* - https://www.mozilla.org/en-US/firefox/channel/desktop/#nightly
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'use strict';
|
|
29
|
-
|
|
30
|
-
const {Builder, By, Key, promise, until} = require('..');
|
|
31
|
-
const {Channel, Options} = require('../firefox');
|
|
32
|
-
|
|
33
|
-
let i = 0;
|
|
34
|
-
function resposition(driver) {
|
|
35
|
-
return driver.manage().window().setRect({
|
|
36
|
-
width: 600,
|
|
37
|
-
height: 400,
|
|
38
|
-
x: 300 * (i++),
|
|
39
|
-
y: 0
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function doSearch(driver) {
|
|
44
|
-
try {
|
|
45
|
-
// Start on the base about page.
|
|
46
|
-
await driver.get('about:')
|
|
47
|
-
// Reposition so users can see the three windows.
|
|
48
|
-
await resposition(driver);
|
|
49
|
-
// Pause so users can see the magic.
|
|
50
|
-
await promise.delayed(750);
|
|
51
|
-
// Now do the rest.
|
|
52
|
-
await driver.get('http://www.google.com/ncr');
|
|
53
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
54
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
55
|
-
console.log('Success!');
|
|
56
|
-
} catch (ex) {
|
|
57
|
-
console.log('An error occured! ' + ex);
|
|
58
|
-
} finally {
|
|
59
|
-
await driver.quit();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function createDriver(channel) {
|
|
64
|
-
let options = new Options().setBinary(channel);
|
|
65
|
-
return new Builder().forBrowser('firefox').setFirefoxOptions(options).build();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Promise.all([
|
|
69
|
-
doSearch(createDriver(Channel.RELEASE)),
|
|
70
|
-
doSearch(createDriver(Channel.AURORA)), // Developer Edition.
|
|
71
|
-
doSearch(createDriver(Channel.NIGHTLY)),
|
|
72
|
-
]).then(_ => {
|
|
73
|
-
console.log('All done!');
|
|
74
|
-
}, err => {
|
|
75
|
-
console.error('An error occured! ' + err);
|
|
76
|
-
setTimeout(() => {throw err}, 0);
|
|
77
|
-
});
|
package/example/google_search.js
DELETED
|
@@ -1,50 +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
|
-
/**
|
|
19
|
-
* @fileoverview An example WebDriver script.
|
|
20
|
-
*
|
|
21
|
-
* Before running this script, ensure that Mozilla's geckodriver is present on
|
|
22
|
-
* your system PATH: <https://github.com/mozilla/geckodriver/releases>
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* // Default behavior
|
|
26
|
-
* node selenium-webdriver/example/google_search.js
|
|
27
|
-
*
|
|
28
|
-
* // Target Chrome locally; the chromedriver must be on your PATH
|
|
29
|
-
* SELENIUM_BROWSER=chrome node selenium-webdriver/example/google_search.js
|
|
30
|
-
*
|
|
31
|
-
* // Use a local copy of the standalone Selenium server
|
|
32
|
-
* SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
|
|
33
|
-
* node selenium-webdriver/example/google_search.js
|
|
34
|
-
*
|
|
35
|
-
* // Target a remote Selenium server
|
|
36
|
-
* SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
|
|
37
|
-
* node selenium-webdriver/example/google_search.js
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
const {Builder, By, Key, until} = require('..');
|
|
41
|
-
|
|
42
|
-
var driver = new Builder()
|
|
43
|
-
.forBrowser('firefox')
|
|
44
|
-
.build();
|
|
45
|
-
|
|
46
|
-
driver.get('http://www.google.com/ncr')
|
|
47
|
-
.then(_ =>
|
|
48
|
-
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
|
|
49
|
-
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
|
50
|
-
.then(_ => driver.quit());
|
|
@@ -1,72 +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
|
-
/**
|
|
19
|
-
* @fileoverview An example test that may be run using Mocha.
|
|
20
|
-
*
|
|
21
|
-
* This example uses the `selenium-webdriver/testing.suite` function, which will
|
|
22
|
-
* automatically run tests against every available WebDriver browser on the
|
|
23
|
-
* current system. Alternatively, you may use the `SELENIUM_BROWSER`
|
|
24
|
-
* environment variable to narrow the scope at runtime.
|
|
25
|
-
*
|
|
26
|
-
* Usage:
|
|
27
|
-
*
|
|
28
|
-
* # Automatically determine which browsers to run against.
|
|
29
|
-
* mocha -t 10000 selenium-webdriver/example/google_search_test.js
|
|
30
|
-
*
|
|
31
|
-
* # Configure tests to only run against Google Chrome.
|
|
32
|
-
* SELENIUM_BROWSER=chrome \
|
|
33
|
-
* mocha -t 10000 selenium-webdriver/example/google_search_test.js
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
const assert = require('assert');
|
|
37
|
-
|
|
38
|
-
const {Browser, By, Key, until} = require('..');
|
|
39
|
-
const {ignore, suite} = require('../testing');
|
|
40
|
-
|
|
41
|
-
suite(function(env) {
|
|
42
|
-
describe('Google Search', function() {
|
|
43
|
-
let driver;
|
|
44
|
-
|
|
45
|
-
before(async function() {
|
|
46
|
-
// env.builder() returns a Builder instance preconfigured for the
|
|
47
|
-
// envrionment's target browser (you may still define browser specific
|
|
48
|
-
// options if necessary (i.e. firefox.Options or chrome.Options)).
|
|
49
|
-
driver = await env.builder().build();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('demo', async function() {
|
|
53
|
-
await driver.get('https://www.google.com/ncr');
|
|
54
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
55
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// The ignore function returns wrappers around describe & it that will
|
|
59
|
-
// suppress tests if the provided predicate returns true. You may provide
|
|
60
|
-
// any synchronous predicate. The env.browsers(...) function generates a
|
|
61
|
-
// predicate that will suppress tests if the env targets one of the
|
|
62
|
-
// specified browsers.
|
|
63
|
-
//
|
|
64
|
-
// This example is always configured to skip Chrome.
|
|
65
|
-
ignore(env.browsers(Browser.CHROME)).it('demo 2', async function() {
|
|
66
|
-
await driver.get('https://www.google.com/ncr');
|
|
67
|
-
await driver.wait(until.urlIs('https://www.google.com/'), 1500);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
after(() => driver && driver.quit());
|
|
71
|
-
});
|
|
72
|
-
});
|
package/example/headless.js
DELETED
|
@@ -1,55 +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
|
-
/**
|
|
19
|
-
* @fileoverview An example of running Chrome or Firefox in headless mode.
|
|
20
|
-
*
|
|
21
|
-
* To run with Chrome, ensure you have Chrome 59+ installed and that
|
|
22
|
-
* chromedriver 2.30+ is present on your system PATH:
|
|
23
|
-
* <https://sites.google.com/a/chromium.org/chromedriver/downloads>
|
|
24
|
-
*
|
|
25
|
-
* SELENIUM_BROWSER=chrome node selenium-webdriver/example/headless.js
|
|
26
|
-
*
|
|
27
|
-
* To run with Firefox, ensure you have Firefox 57+ installed and that
|
|
28
|
-
* geckodriver 0.19.0+ is present on your system PATH:
|
|
29
|
-
* <https://github.com/mozilla/geckodriver/releases>
|
|
30
|
-
*
|
|
31
|
-
* SELENIUM_BROWSER=firefox node selenium-webdriver/example/headless.js
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
const chrome = require('../chrome');
|
|
35
|
-
const firefox = require('../firefox');
|
|
36
|
-
const {Builder, By, Key, until} = require('..');
|
|
37
|
-
|
|
38
|
-
const width = 640;
|
|
39
|
-
const height = 480;
|
|
40
|
-
|
|
41
|
-
let driver = new Builder()
|
|
42
|
-
.forBrowser('chrome')
|
|
43
|
-
.setChromeOptions(
|
|
44
|
-
new chrome.Options().headless().windowSize({width, height}))
|
|
45
|
-
.setFirefoxOptions(
|
|
46
|
-
new firefox.Options().headless().windowSize({width, height}))
|
|
47
|
-
.build();
|
|
48
|
-
|
|
49
|
-
driver.get('http://www.google.com/ncr')
|
|
50
|
-
.then(_ =>
|
|
51
|
-
driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN))
|
|
52
|
-
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
|
|
53
|
-
.then(
|
|
54
|
-
_ => driver.quit(),
|
|
55
|
-
e => driver.quit().then(() => { throw e; }));
|
package/example/logging.js
DELETED
|
@@ -1,68 +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
|
-
/**
|
|
19
|
-
* @fileoverview Demonstrates how to use WebDriver's logging sysem.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
'use strict';
|
|
23
|
-
|
|
24
|
-
const chrome = require('../chrome');
|
|
25
|
-
const firefox = require('../firefox');
|
|
26
|
-
const edge = require('../edge');
|
|
27
|
-
const {Builder, By, Key, logging, until} = require('..');
|
|
28
|
-
|
|
29
|
-
logging.installConsoleHandler();
|
|
30
|
-
logging.getLogger('webdriver.http').setLevel(logging.Level.ALL);
|
|
31
|
-
|
|
32
|
-
(async function() {
|
|
33
|
-
let driver;
|
|
34
|
-
try {
|
|
35
|
-
driver = await new Builder()
|
|
36
|
-
// Default to using Firefox. This can be overridden at runtime by
|
|
37
|
-
// setting the SELENIUM_BROWSER environment variable:
|
|
38
|
-
//
|
|
39
|
-
// SELENIUM_BROWSER=chrome node selenium-webdriver/example/logging.js
|
|
40
|
-
.forBrowser('firefox')
|
|
41
|
-
// Configure the service for each browser to enable verbose logging and
|
|
42
|
-
// to inherit the stdio settings from the current process. The builder
|
|
43
|
-
// will only start the service if needed for the selected browser.
|
|
44
|
-
.setChromeService(
|
|
45
|
-
new chrome.ServiceBuilder()
|
|
46
|
-
.enableVerboseLogging()
|
|
47
|
-
.setStdio('inherit'))
|
|
48
|
-
.setEdgeService(
|
|
49
|
-
process.platform === 'win32'
|
|
50
|
-
? new edge.ServiceBuilder()
|
|
51
|
-
.enableVerboseLogging()
|
|
52
|
-
.setStdio('inherit')
|
|
53
|
-
: null)
|
|
54
|
-
.setFirefoxService(
|
|
55
|
-
new firefox.ServiceBuilder()
|
|
56
|
-
.enableVerboseLogging()
|
|
57
|
-
.setStdio('inherit'))
|
|
58
|
-
.build();
|
|
59
|
-
|
|
60
|
-
await driver.get('http://www.google.com/ncr');
|
|
61
|
-
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
62
|
-
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
63
|
-
} finally {
|
|
64
|
-
if (driver) {
|
|
65
|
-
await driver.quit();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
})();
|
package/jasmine.json
DELETED
package/lib/atoms/BUILD.bazel
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
|
|
2
|
-
|
|
3
|
-
nodejs_binary(
|
|
4
|
-
name = "make_atoms_module",
|
|
5
|
-
data = ["make-atoms-module.js"],
|
|
6
|
-
entry_point = "selenium/javascript/node/selenium-webdriver/lib/atoms/make-atoms-module",
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
# genrules used to copy closure_js_binary outputs to locations
|
|
10
|
-
# that will be picked up by the npm_package rule.
|
|
11
|
-
|
|
12
|
-
genrule(
|
|
13
|
-
name = "is_displayed",
|
|
14
|
-
srcs = ["//javascript/atoms/fragments:is-displayed.js"],
|
|
15
|
-
outs = ["is-displayed.js"],
|
|
16
|
-
cmd = "$(location :make_atoms_module) $< $@",
|
|
17
|
-
tools = [":make_atoms_module"],
|
|
18
|
-
visibility = ["//javascript/node/selenium-webdriver:__pkg__"],
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
genrule(
|
|
22
|
-
name = "get_attribute",
|
|
23
|
-
srcs = ["//javascript/webdriver/atoms:get-attribute.js"],
|
|
24
|
-
outs = ["get-attribute.js"],
|
|
25
|
-
cmd = "$(location :make_atoms_module) $< $@",
|
|
26
|
-
tools = [":make_atoms_module"],
|
|
27
|
-
visibility = ["//javascript/node/selenium-webdriver:__pkg__"],
|
|
28
|
-
)
|