selenium-webdriver 4.0.0-alpha.8 → 4.0.0-beta.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/CHANGES.md +41 -1
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +0 -0
- package/chrome.js +0 -0
- package/chromium.js +23 -202
- package/devtools/CDPConnection.js +16 -18
- package/edge.js +89 -130
- package/example/chrome_android.js +45 -0
- package/{lib/atoms/make-atoms-module.js → example/chrome_mobile_emulation.js} +26 -15
- package/example/firefox_channels.js +84 -0
- package/example/google_search.js +50 -0
- package/example/google_search_test.js +70 -0
- package/example/headless.js +63 -0
- package/example/logging.js +64 -0
- package/firefox.js +10 -9
- package/http/index.js +0 -0
- package/http/util.js +3 -3
- package/ie.js +0 -0
- package/index.js +2 -2
- package/io/exec.js +3 -3
- package/io/index.js +12 -13
- package/io/zip.js +5 -6
- package/lib/atoms/find-elements.js +78 -78
- package/lib/atoms/get-attribute.js +64 -68
- package/lib/atoms/is-displayed.js +27 -27
- package/lib/atoms/mutation-listener.js +55 -0
- package/lib/by.js +1 -1
- package/lib/capabilities.js +2 -3
- package/lib/command.js +2 -15
- package/lib/error.js +0 -0
- package/lib/http.js +17 -30
- package/lib/input.js +2 -286
- package/lib/logging.js +0 -0
- package/lib/promise.js +4 -16
- package/lib/proxy.js +0 -0
- package/lib/session.js +0 -0
- package/lib/symbols.js +0 -0
- package/lib/until.js +17 -15
- package/lib/webdriver.js +336 -16
- package/net/index.js +0 -0
- package/net/portprober.js +8 -8
- package/opera.js +0 -0
- package/package.json +13 -13
- package/proxy.js +0 -0
- package/remote/index.js +6 -7
- package/safari.js +0 -0
- package/testing/index.js +504 -0
- package/.eslintrc.js +0 -27
- package/.prettierrc +0 -4
- package/devtools/generator/protocol-dts-generator.js +0 -429
- package/lib/README +0 -5
- package/lib/actions.js +0 -626
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
;(async function () {
|
|
32
|
+
let driver
|
|
33
|
+
try {
|
|
34
|
+
driver = await new Builder()
|
|
35
|
+
// Default to using Firefox. This can be overridden at runtime by
|
|
36
|
+
// setting the SELENIUM_BROWSER environment variable:
|
|
37
|
+
//
|
|
38
|
+
// SELENIUM_BROWSER=chrome node selenium-webdriver/example/logging.js
|
|
39
|
+
.forBrowser('firefox')
|
|
40
|
+
// Configure the service for each browser to enable verbose logging and
|
|
41
|
+
// to inherit the stdio settings from the current process. The builder
|
|
42
|
+
// will only start the service if needed for the selected browser.
|
|
43
|
+
.setChromeService(
|
|
44
|
+
new chrome.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
|
45
|
+
)
|
|
46
|
+
.setEdgeService(
|
|
47
|
+
process.platform === 'win32'
|
|
48
|
+
? new edge.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
|
49
|
+
: null
|
|
50
|
+
)
|
|
51
|
+
.setFirefoxService(
|
|
52
|
+
new firefox.ServiceBuilder().enableVerboseLogging().setStdio('inherit')
|
|
53
|
+
)
|
|
54
|
+
.build()
|
|
55
|
+
|
|
56
|
+
await driver.get('http://www.google.com/ncr')
|
|
57
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
|
|
58
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
|
|
59
|
+
} finally {
|
|
60
|
+
if (driver) {
|
|
61
|
+
await driver.quit()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})()
|
package/firefox.js
CHANGED
|
@@ -124,6 +124,7 @@ const io = require('./io')
|
|
|
124
124
|
const remote = require('./remote')
|
|
125
125
|
const webdriver = require('./lib/webdriver')
|
|
126
126
|
const zip = require('./io/zip')
|
|
127
|
+
const cdp = require('./devtools/CDPConnection')
|
|
127
128
|
const { Browser, Capabilities } = require('./lib/capabilities')
|
|
128
129
|
const { Zip } = require('./io/zip')
|
|
129
130
|
|
|
@@ -222,7 +223,7 @@ async function buildProfile(template, extensions) {
|
|
|
222
223
|
dir = await io.tmpDir()
|
|
223
224
|
if (template) {
|
|
224
225
|
await io.copyDir(
|
|
225
|
-
/** @type {string} */
|
|
226
|
+
/** @type {string} */(template),
|
|
226
227
|
dir,
|
|
227
228
|
/(parent\.lock|lock|\.parentlock)/
|
|
228
229
|
)
|
|
@@ -432,11 +433,11 @@ function findGeckoDriver() {
|
|
|
432
433
|
if (!exe) {
|
|
433
434
|
throw Error(
|
|
434
435
|
'The ' +
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
436
|
+
GECKO_DRIVER_EXE +
|
|
437
|
+
' executable could not be found on the current ' +
|
|
438
|
+
'PATH. Please download the latest version from ' +
|
|
439
|
+
'https://github.com/mozilla/geckodriver/releases/ ' +
|
|
440
|
+
'and ensure it can be found on your PATH.'
|
|
440
441
|
)
|
|
441
442
|
}
|
|
442
443
|
return exe
|
|
@@ -457,8 +458,8 @@ function findInProgramFiles(file) {
|
|
|
457
458
|
return exists
|
|
458
459
|
? files[0]
|
|
459
460
|
: io.exists(files[1]).then(function (exists) {
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
return exists ? files[1] : null
|
|
462
|
+
})
|
|
462
463
|
})
|
|
463
464
|
}
|
|
464
465
|
|
|
@@ -592,7 +593,7 @@ class Driver extends webdriver.WebDriver {
|
|
|
592
593
|
* implementation.
|
|
593
594
|
* @override
|
|
594
595
|
*/
|
|
595
|
-
setFileDetector() {}
|
|
596
|
+
setFileDetector() { }
|
|
596
597
|
|
|
597
598
|
/**
|
|
598
599
|
* Get the context that is currently in effect.
|
package/http/index.js
CHANGED
|
File without changes
|
package/http/util.js
CHANGED
|
@@ -35,9 +35,9 @@ const Executor = require('./index').Executor,
|
|
|
35
35
|
* a hash of the server status.
|
|
36
36
|
*/
|
|
37
37
|
function getStatus(url) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const client = new HttpClient(url)
|
|
39
|
+
const executor = new Executor(client)
|
|
40
|
+
const command = new Command(CommandName.GET_SERVER_STATUS)
|
|
41
41
|
return executor.execute(command)
|
|
42
42
|
}
|
|
43
43
|
|
package/ie.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -598,9 +598,9 @@ class Builder {
|
|
|
598
598
|
build() {
|
|
599
599
|
// Create a copy for any changes we may need to make based on the current
|
|
600
600
|
// environment.
|
|
601
|
-
|
|
601
|
+
const capabilities = new Capabilities(this.capabilities_)
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
let browser
|
|
604
604
|
if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
|
|
605
605
|
this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`)
|
|
606
606
|
browser = process.env.SELENIUM_BROWSER.split(/:/, 3)
|
package/io/exec.js
CHANGED
|
@@ -121,9 +121,9 @@ class Command {
|
|
|
121
121
|
* @return {!Command} The launched command.
|
|
122
122
|
*/
|
|
123
123
|
module.exports = function exec(command, opt_options) {
|
|
124
|
-
|
|
124
|
+
const options = opt_options || {}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
let proc = childProcess.spawn(command, options.args || [], {
|
|
127
127
|
env: options.env || process.env,
|
|
128
128
|
stdio: options.stdio || 'ignore',
|
|
129
129
|
})
|
|
@@ -133,7 +133,7 @@ module.exports = function exec(command, opt_options) {
|
|
|
133
133
|
proc.unref()
|
|
134
134
|
process.once('exit', onProcessExit)
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
const result = new Promise((resolve) => {
|
|
137
137
|
proc.once('exit', (code, signal) => {
|
|
138
138
|
proc = null
|
|
139
139
|
process.removeListener('exit', onProcessExit)
|
package/io/index.js
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
|
|
18
18
|
'use strict'
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const fs = require('fs')
|
|
21
|
+
const path = require('path')
|
|
22
|
+
const rimraf = require('rimraf')
|
|
23
|
+
const tmp = require('tmp')
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @param {!Function} fn .
|
|
@@ -204,13 +204,12 @@ exports.tmpDir = function () {
|
|
|
204
204
|
*/
|
|
205
205
|
exports.tmpFile = function (opt_options) {
|
|
206
206
|
return checkedCall((callback) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
207
|
+
/** check fixed in v > 0.2.1 if
|
|
208
|
+
* (typeof options === 'function') {
|
|
209
|
+
* return [{}, options];
|
|
210
|
+
* }
|
|
211
|
+
*/
|
|
212
|
+
tmp.file(opt_options, callback)
|
|
214
213
|
})
|
|
215
214
|
}
|
|
216
215
|
|
|
@@ -224,7 +223,7 @@ exports.tmpFile = function (opt_options) {
|
|
|
224
223
|
* not be found.
|
|
225
224
|
*/
|
|
226
225
|
exports.findInPath = function (file, opt_checkCwd) {
|
|
227
|
-
|
|
226
|
+
const dirs = []
|
|
228
227
|
if (opt_checkCwd) {
|
|
229
228
|
dirs.push(process.cwd())
|
|
230
229
|
}
|
|
@@ -329,7 +328,7 @@ exports.mkdirp = function mkdirp(dir) {
|
|
|
329
328
|
* will be relative to `rootPath`.
|
|
330
329
|
*/
|
|
331
330
|
exports.walkDir = function (rootPath) {
|
|
332
|
-
|
|
331
|
+
const seen = []
|
|
333
332
|
return (function walk(dir) {
|
|
334
333
|
return checkedCall((callback) => fs.readdir(dir, callback)).then((files) =>
|
|
335
334
|
Promise.all(
|
package/io/zip.js
CHANGED
|
@@ -180,8 +180,8 @@ function load(path) {
|
|
|
180
180
|
*/
|
|
181
181
|
function unzip(src, dst) {
|
|
182
182
|
return load(src).then((zip) => {
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
const promisedDirs = new Map()
|
|
184
|
+
const promises = []
|
|
185
185
|
|
|
186
186
|
zip.z_.forEach((relPath, file) => {
|
|
187
187
|
let p
|
|
@@ -218,7 +218,6 @@ function unzip(src, dst) {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
// PUBLIC API
|
|
221
|
-
|
|
222
|
-
exports.
|
|
223
|
-
exports.
|
|
224
|
-
exports.unzip = unzip
|
|
221
|
+
module.exports.Zip = Zip
|
|
222
|
+
module.exports.load = load
|
|
223
|
+
module.exports.unzip = unzip
|