UrgentcareCLI 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/UrgentCare/CLI.rb +1 -2
- data/lib/UrgentCare/Scraper.rb +65 -0
- data/lib/UrgentCare/version.rb +2 -2
- data/lib/UrgentCare.rb +1 -0
- metadata +3 -313
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -84
- data/LICENSE.txt +0 -21
- data/Notes +0 -41
- data/README.md +0 -41
- data/Rakefile +0 -8
- data/UrgentCare.gemspec +0 -39
- data/background.jpg +0 -0
- data/data.txt +0 -4
- data/lib/Urgentcare/Scraper.rb +0 -78
- data/node_modules/.bin/rimraf +0 -1
- data/node_modules/.package-lock.json +0 -250
- data/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- data/node_modules/balanced-match/LICENSE.md +0 -21
- data/node_modules/balanced-match/README.md +0 -97
- data/node_modules/balanced-match/index.js +0 -62
- data/node_modules/balanced-match/package.json +0 -48
- data/node_modules/brace-expansion/LICENSE +0 -21
- data/node_modules/brace-expansion/README.md +0 -129
- data/node_modules/brace-expansion/index.js +0 -201
- data/node_modules/brace-expansion/package.json +0 -47
- data/node_modules/concat-map/.travis.yml +0 -4
- data/node_modules/concat-map/LICENSE +0 -18
- data/node_modules/concat-map/README.markdown +0 -62
- data/node_modules/concat-map/example/map.js +0 -6
- data/node_modules/concat-map/index.js +0 -13
- data/node_modules/concat-map/package.json +0 -43
- data/node_modules/concat-map/test/map.js +0 -39
- data/node_modules/core-util-is/LICENSE +0 -19
- data/node_modules/core-util-is/README.md +0 -3
- data/node_modules/core-util-is/float.patch +0 -604
- data/node_modules/core-util-is/lib/util.js +0 -107
- data/node_modules/core-util-is/package.json +0 -32
- data/node_modules/core-util-is/test.js +0 -68
- data/node_modules/fs.realpath/LICENSE +0 -43
- data/node_modules/fs.realpath/README.md +0 -33
- data/node_modules/fs.realpath/index.js +0 -66
- data/node_modules/fs.realpath/old.js +0 -303
- data/node_modules/fs.realpath/package.json +0 -26
- data/node_modules/glob/LICENSE +0 -21
- data/node_modules/glob/README.md +0 -375
- data/node_modules/glob/changelog.md +0 -67
- data/node_modules/glob/common.js +0 -234
- data/node_modules/glob/glob.js +0 -788
- data/node_modules/glob/package.json +0 -51
- data/node_modules/glob/sync.js +0 -484
- data/node_modules/immediate/LICENSE.txt +0 -20
- data/node_modules/immediate/README.md +0 -93
- data/node_modules/immediate/dist/immediate.js +0 -75
- data/node_modules/immediate/dist/immediate.min.js +0 -1
- data/node_modules/immediate/lib/browser.js +0 -69
- data/node_modules/immediate/lib/index.js +0 -73
- data/node_modules/immediate/package.json +0 -42
- data/node_modules/inflight/LICENSE +0 -15
- data/node_modules/inflight/README.md +0 -37
- data/node_modules/inflight/inflight.js +0 -54
- data/node_modules/inflight/package.json +0 -29
- data/node_modules/inherits/LICENSE +0 -16
- data/node_modules/inherits/README.md +0 -42
- data/node_modules/inherits/inherits.js +0 -9
- data/node_modules/inherits/inherits_browser.js +0 -27
- data/node_modules/inherits/package.json +0 -29
- data/node_modules/isarray/.npmignore +0 -1
- data/node_modules/isarray/.travis.yml +0 -4
- data/node_modules/isarray/Makefile +0 -6
- data/node_modules/isarray/README.md +0 -60
- data/node_modules/isarray/component.json +0 -19
- data/node_modules/isarray/index.js +0 -5
- data/node_modules/isarray/package.json +0 -45
- data/node_modules/isarray/test.js +0 -20
- data/node_modules/jszip/.codeclimate.yml +0 -16
- data/node_modules/jszip/.editorconfig +0 -8
- data/node_modules/jszip/.jshintignore +0 -1
- data/node_modules/jszip/.jshintrc +0 -21
- data/node_modules/jszip/.travis.yml +0 -17
- data/node_modules/jszip/CHANGES.md +0 -163
- data/node_modules/jszip/LICENSE.markdown +0 -651
- data/node_modules/jszip/README.markdown +0 -35
- data/node_modules/jszip/dist/jszip.js +0 -30
- data/node_modules/jszip/dist/jszip.min.js +0 -13
- data/node_modules/jszip/index.d.ts +0 -270
- data/node_modules/jszip/lib/base64.js +0 -106
- data/node_modules/jszip/lib/compressedObject.js +0 -74
- data/node_modules/jszip/lib/compressions.js +0 -14
- data/node_modules/jszip/lib/crc32.js +0 -77
- data/node_modules/jszip/lib/defaults.js +0 -11
- data/node_modules/jszip/lib/external.js +0 -19
- data/node_modules/jszip/lib/flate.js +0 -85
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -540
- data/node_modules/jszip/lib/generate/index.js +0 -57
- data/node_modules/jszip/lib/index.js +0 -52
- data/node_modules/jszip/lib/license_header.js +0 -11
- data/node_modules/jszip/lib/load.js +0 -81
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
- data/node_modules/jszip/lib/nodejsUtils.js +0 -57
- data/node_modules/jszip/lib/object.js +0 -389
- data/node_modules/jszip/lib/readable-stream-browser.js +0 -9
- data/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
- data/node_modules/jszip/lib/reader/DataReader.js +0 -116
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
- data/node_modules/jszip/lib/reader/StringReader.js +0 -38
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
- data/node_modules/jszip/lib/reader/readerFor.js +0 -28
- data/node_modules/jszip/lib/signature.js +0 -7
- data/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
- data/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
- data/node_modules/jszip/lib/stream/DataWorker.js +0 -116
- data/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
- data/node_modules/jszip/lib/stream/StreamHelper.js +0 -212
- data/node_modules/jszip/lib/support.js +0 -38
- data/node_modules/jszip/lib/utf8.js +0 -275
- data/node_modules/jszip/lib/utils.js +0 -476
- data/node_modules/jszip/lib/zipEntries.js +0 -262
- data/node_modules/jszip/lib/zipEntry.js +0 -294
- data/node_modules/jszip/lib/zipObject.js +0 -133
- data/node_modules/jszip/package.json +0 -63
- data/node_modules/jszip/vendor/FileSaver.js +0 -247
- data/node_modules/lie/README.md +0 -62
- data/node_modules/lie/dist/lie.js +0 -350
- data/node_modules/lie/dist/lie.min.js +0 -1
- data/node_modules/lie/dist/lie.polyfill.js +0 -358
- data/node_modules/lie/dist/lie.polyfill.min.js +0 -1
- data/node_modules/lie/lib/browser.js +0 -273
- data/node_modules/lie/lib/index.js +0 -298
- data/node_modules/lie/license.md +0 -7
- data/node_modules/lie/lie.d.ts +0 -244
- data/node_modules/lie/package.json +0 -69
- data/node_modules/lie/polyfill.js +0 -4
- data/node_modules/minimatch/LICENSE +0 -15
- data/node_modules/minimatch/README.md +0 -209
- data/node_modules/minimatch/minimatch.js +0 -923
- data/node_modules/minimatch/package.json +0 -30
- data/node_modules/once/LICENSE +0 -15
- data/node_modules/once/README.md +0 -79
- data/node_modules/once/once.js +0 -42
- data/node_modules/once/package.json +0 -33
- data/node_modules/pako/CHANGELOG.md +0 -164
- data/node_modules/pako/LICENSE +0 -21
- data/node_modules/pako/README.md +0 -191
- data/node_modules/pako/dist/pako.js +0 -6818
- data/node_modules/pako/dist/pako.min.js +0 -1
- data/node_modules/pako/dist/pako_deflate.js +0 -3997
- data/node_modules/pako/dist/pako_deflate.min.js +0 -1
- data/node_modules/pako/dist/pako_inflate.js +0 -3300
- data/node_modules/pako/dist/pako_inflate.min.js +0 -1
- data/node_modules/pako/index.js +0 -14
- data/node_modules/pako/lib/deflate.js +0 -400
- data/node_modules/pako/lib/inflate.js +0 -423
- data/node_modules/pako/lib/utils/common.js +0 -105
- data/node_modules/pako/lib/utils/strings.js +0 -187
- data/node_modules/pako/lib/zlib/README +0 -59
- data/node_modules/pako/lib/zlib/adler32.js +0 -51
- data/node_modules/pako/lib/zlib/constants.js +0 -68
- data/node_modules/pako/lib/zlib/crc32.js +0 -59
- data/node_modules/pako/lib/zlib/deflate.js +0 -1874
- data/node_modules/pako/lib/zlib/gzheader.js +0 -58
- data/node_modules/pako/lib/zlib/inffast.js +0 -345
- data/node_modules/pako/lib/zlib/inflate.js +0 -1556
- data/node_modules/pako/lib/zlib/inftrees.js +0 -343
- data/node_modules/pako/lib/zlib/messages.js +0 -32
- data/node_modules/pako/lib/zlib/trees.js +0 -1222
- data/node_modules/pako/lib/zlib/zstream.js +0 -47
- data/node_modules/pako/package.json +0 -44
- data/node_modules/path-is-absolute/index.js +0 -20
- data/node_modules/path-is-absolute/license +0 -21
- data/node_modules/path-is-absolute/package.json +0 -43
- data/node_modules/path-is-absolute/readme.md +0 -59
- data/node_modules/process-nextick-args/index.js +0 -45
- data/node_modules/process-nextick-args/license.md +0 -19
- data/node_modules/process-nextick-args/package.json +0 -25
- data/node_modules/process-nextick-args/readme.md +0 -18
- data/node_modules/readable-stream/.travis.yml +0 -34
- data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- data/node_modules/readable-stream/GOVERNANCE.md +0 -136
- data/node_modules/readable-stream/LICENSE +0 -47
- data/node_modules/readable-stream/README.md +0 -58
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- data/node_modules/readable-stream/duplex-browser.js +0 -1
- data/node_modules/readable-stream/duplex.js +0 -1
- data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- data/node_modules/readable-stream/package.json +0 -52
- data/node_modules/readable-stream/passthrough.js +0 -1
- data/node_modules/readable-stream/readable-browser.js +0 -7
- data/node_modules/readable-stream/readable.js +0 -19
- data/node_modules/readable-stream/transform.js +0 -1
- data/node_modules/readable-stream/writable-browser.js +0 -1
- data/node_modules/readable-stream/writable.js +0 -8
- data/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/rimraf/README.md +0 -101
- data/node_modules/rimraf/bin.js +0 -50
- data/node_modules/rimraf/package.json +0 -29
- data/node_modules/rimraf/rimraf.js +0 -372
- data/node_modules/safe-buffer/LICENSE +0 -21
- data/node_modules/safe-buffer/README.md +0 -584
- data/node_modules/safe-buffer/index.d.ts +0 -187
- data/node_modules/safe-buffer/index.js +0 -62
- data/node_modules/safe-buffer/package.json +0 -37
- data/node_modules/selenium-webdriver/CHANGES.md +0 -1114
- data/node_modules/selenium-webdriver/LICENSE +0 -202
- data/node_modules/selenium-webdriver/NOTICE +0 -2
- data/node_modules/selenium-webdriver/README.md +0 -229
- data/node_modules/selenium-webdriver/chrome.js +0 -295
- data/node_modules/selenium-webdriver/chromium.js +0 -829
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +0 -35
- data/node_modules/selenium-webdriver/edge.js +0 -224
- data/node_modules/selenium-webdriver/example/chrome_android.js +0 -45
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +0 -46
- data/node_modules/selenium-webdriver/example/firefox_channels.js +0 -84
- data/node_modules/selenium-webdriver/example/google_search.js +0 -50
- data/node_modules/selenium-webdriver/example/google_search_test.js +0 -70
- data/node_modules/selenium-webdriver/example/headless.js +0 -63
- data/node_modules/selenium-webdriver/example/logging.js +0 -64
- data/node_modules/selenium-webdriver/firefox.js +0 -789
- data/node_modules/selenium-webdriver/http/index.js +0 -324
- data/node_modules/selenium-webdriver/http/util.js +0 -172
- data/node_modules/selenium-webdriver/ie.js +0 -503
- data/node_modules/selenium-webdriver/index.js +0 -825
- data/node_modules/selenium-webdriver/io/exec.js +0 -162
- data/node_modules/selenium-webdriver/io/index.js +0 -348
- data/node_modules/selenium-webdriver/io/zip.js +0 -223
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +0 -123
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +0 -55
- data/node_modules/selenium-webdriver/lib/by.js +0 -415
- data/node_modules/selenium-webdriver/lib/capabilities.js +0 -553
- data/node_modules/selenium-webdriver/lib/command.js +0 -206
- data/node_modules/selenium-webdriver/lib/error.js +0 -605
- data/node_modules/selenium-webdriver/lib/http.js +0 -704
- data/node_modules/selenium-webdriver/lib/input.js +0 -946
- data/node_modules/selenium-webdriver/lib/logging.js +0 -661
- data/node_modules/selenium-webdriver/lib/promise.js +0 -285
- data/node_modules/selenium-webdriver/lib/proxy.js +0 -212
- data/node_modules/selenium-webdriver/lib/session.js +0 -77
- data/node_modules/selenium-webdriver/lib/symbols.js +0 -37
- data/node_modules/selenium-webdriver/lib/until.js +0 -429
- data/node_modules/selenium-webdriver/lib/webdriver.js +0 -2919
- data/node_modules/selenium-webdriver/net/index.js +0 -107
- data/node_modules/selenium-webdriver/net/portprober.js +0 -75
- data/node_modules/selenium-webdriver/opera.js +0 -406
- data/node_modules/selenium-webdriver/package.json +0 -54
- data/node_modules/selenium-webdriver/proxy.js +0 -32
- data/node_modules/selenium-webdriver/remote/index.js +0 -624
- data/node_modules/selenium-webdriver/safari.js +0 -168
- data/node_modules/selenium-webdriver/testing/index.js +0 -504
- data/node_modules/set-immediate-shim/index.js +0 -7
- data/node_modules/set-immediate-shim/package.json +0 -34
- data/node_modules/set-immediate-shim/readme.md +0 -31
- data/node_modules/string_decoder/.travis.yml +0 -50
- data/node_modules/string_decoder/LICENSE +0 -48
- data/node_modules/string_decoder/README.md +0 -47
- data/node_modules/string_decoder/lib/string_decoder.js +0 -296
- data/node_modules/string_decoder/package.json +0 -31
- data/node_modules/tmp/CHANGELOG.md +0 -288
- data/node_modules/tmp/LICENSE +0 -21
- data/node_modules/tmp/README.md +0 -365
- data/node_modules/tmp/lib/tmp.js +0 -780
- data/node_modules/tmp/node_modules/.bin/rimraf +0 -1
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +0 -65
- data/node_modules/tmp/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/tmp/node_modules/rimraf/README.md +0 -101
- data/node_modules/tmp/node_modules/rimraf/bin.js +0 -68
- data/node_modules/tmp/node_modules/rimraf/package.json +0 -32
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +0 -360
- data/node_modules/tmp/package.json +0 -58
- data/node_modules/util-deprecate/History.md +0 -16
- data/node_modules/util-deprecate/LICENSE +0 -24
- data/node_modules/util-deprecate/README.md +0 -53
- data/node_modules/util-deprecate/browser.js +0 -67
- data/node_modules/util-deprecate/node.js +0 -6
- data/node_modules/util-deprecate/package.json +0 -27
- data/node_modules/wrappy/LICENSE +0 -15
- data/node_modules/wrappy/README.md +0 -36
- data/node_modules/wrappy/package.json +0 -29
- data/node_modules/wrappy/wrappy.js +0 -33
- data/node_modules/ws/LICENSE +0 -21
- data/node_modules/ws/README.md +0 -496
- data/node_modules/ws/browser.js +0 -8
- data/node_modules/ws/index.js +0 -10
- data/node_modules/ws/lib/buffer-util.js +0 -129
- data/node_modules/ws/lib/constants.js +0 -10
- data/node_modules/ws/lib/event-target.js +0 -184
- data/node_modules/ws/lib/extension.js +0 -223
- data/node_modules/ws/lib/limiter.js +0 -55
- data/node_modules/ws/lib/permessage-deflate.js +0 -517
- data/node_modules/ws/lib/receiver.js +0 -507
- data/node_modules/ws/lib/sender.js +0 -405
- data/node_modules/ws/lib/stream.js +0 -165
- data/node_modules/ws/lib/validation.js +0 -104
- data/node_modules/ws/lib/websocket-server.js +0 -418
- data/node_modules/ws/lib/websocket.js +0 -942
- data/node_modules/ws/package.json +0 -56
- data/package-lock.json +0 -458
- data/package.json +0 -5
- data/selenium.log +0 -1
- data/spec.md +0 -6
- data/test.data +0 -2110
@@ -1,825 +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 The main user facing module. Exports WebDriver's primary
|
20
|
-
* public API and provides convenience assessors to certain sub-modules.
|
21
|
-
*/
|
22
|
-
|
23
|
-
'use strict'
|
24
|
-
|
25
|
-
const _http = require('./http')
|
26
|
-
const by = require('./lib/by')
|
27
|
-
const capabilities = require('./lib/capabilities')
|
28
|
-
const chrome = require('./chrome')
|
29
|
-
const edge = require('./edge')
|
30
|
-
const error = require('./lib/error')
|
31
|
-
const firefox = require('./firefox')
|
32
|
-
const ie = require('./ie')
|
33
|
-
const input = require('./lib/input')
|
34
|
-
const logging = require('./lib/logging')
|
35
|
-
const promise = require('./lib/promise')
|
36
|
-
const remote = require('./remote')
|
37
|
-
const safari = require('./safari')
|
38
|
-
const session = require('./lib/session')
|
39
|
-
const until = require('./lib/until')
|
40
|
-
const webdriver = require('./lib/webdriver')
|
41
|
-
const opera = require('./opera')
|
42
|
-
|
43
|
-
const Browser = capabilities.Browser
|
44
|
-
const Capabilities = capabilities.Capabilities
|
45
|
-
const Capability = capabilities.Capability
|
46
|
-
const WebDriver = webdriver.WebDriver
|
47
|
-
|
48
|
-
var seleniumServer
|
49
|
-
|
50
|
-
/**
|
51
|
-
* Starts an instance of the Selenium server if not yet running.
|
52
|
-
* @param {string} jar Path to the server jar to use.
|
53
|
-
* @return {!Promise<string>} A promise for the server's
|
54
|
-
* address once started.
|
55
|
-
*/
|
56
|
-
function startSeleniumServer(jar) {
|
57
|
-
if (!seleniumServer) {
|
58
|
-
seleniumServer = new remote.SeleniumServer(jar)
|
59
|
-
}
|
60
|
-
return seleniumServer.start()
|
61
|
-
}
|
62
|
-
|
63
|
-
/**
|
64
|
-
* {@linkplain webdriver.WebDriver#setFileDetector WebDriver's setFileDetector}
|
65
|
-
* method uses a non-standard command to transfer files from the local client
|
66
|
-
* to the remote end hosting the browser. Many of the WebDriver sub-types, like
|
67
|
-
* the {@link chrome.Driver} and {@link firefox.Driver}, do not support this
|
68
|
-
* command. Thus, these classes override the `setFileDetector` to no-op.
|
69
|
-
*
|
70
|
-
* This function uses a mixin to re-enable `setFileDetector` by calling the
|
71
|
-
* original method on the WebDriver prototype directly. This is used only when
|
72
|
-
* the builder creates a Chrome or Firefox instance that communicates with a
|
73
|
-
* remote end (and thus, support for remote file detectors is unknown).
|
74
|
-
*
|
75
|
-
* @param {function(new: webdriver.WebDriver, ...?)} ctor
|
76
|
-
* @return {function(new: webdriver.WebDriver, ...?)}
|
77
|
-
*/
|
78
|
-
function ensureFileDetectorsAreEnabled(ctor) {
|
79
|
-
const mixin = class extends ctor {
|
80
|
-
/** @param {input.FileDetector} detector */
|
81
|
-
setFileDetector(detector) {
|
82
|
-
webdriver.WebDriver.prototype.setFileDetector.call(this, detector)
|
83
|
-
}
|
84
|
-
}
|
85
|
-
return mixin
|
86
|
-
}
|
87
|
-
|
88
|
-
/**
|
89
|
-
* A thenable wrapper around a {@linkplain webdriver.IWebDriver IWebDriver}
|
90
|
-
* instance that allows commands to be issued directly instead of having to
|
91
|
-
* repeatedly call `then`:
|
92
|
-
*
|
93
|
-
* let driver = new Builder().build();
|
94
|
-
* driver.then(d => d.get(url)); // You can do this...
|
95
|
-
* driver.get(url); // ...or this
|
96
|
-
*
|
97
|
-
* If the driver instance fails to resolve (e.g. the session cannot be created),
|
98
|
-
* every issued command will fail.
|
99
|
-
*
|
100
|
-
* @extends {webdriver.IWebDriver}
|
101
|
-
* @extends {IThenable<!webdriver.IWebDriver>}
|
102
|
-
* @interface
|
103
|
-
*/
|
104
|
-
class ThenableWebDriver {
|
105
|
-
/** @param {...?} args */
|
106
|
-
static createSession(...args) {} // eslint-disable-line
|
107
|
-
}
|
108
|
-
|
109
|
-
/**
|
110
|
-
* @const {!Map<function(new: WebDriver, !IThenable<!Session>, ...?),
|
111
|
-
* function(new: ThenableWebDriver, !IThenable<!Session>, ...?)>}
|
112
|
-
*/
|
113
|
-
const THENABLE_DRIVERS = new Map()
|
114
|
-
|
115
|
-
/**
|
116
|
-
* @param {function(new: WebDriver, !IThenable<!Session>, ...?)} ctor
|
117
|
-
* @param {...?} args
|
118
|
-
* @return {!ThenableWebDriver}
|
119
|
-
*/
|
120
|
-
function createDriver(ctor, ...args) {
|
121
|
-
let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor)
|
122
|
-
if (!thenableWebDriverProxy) {
|
123
|
-
/**
|
124
|
-
* @extends {WebDriver} // Needed since `ctor` is dynamically typed.
|
125
|
-
* @implements {ThenableWebDriver}
|
126
|
-
*/
|
127
|
-
thenableWebDriverProxy = class extends ctor {
|
128
|
-
/**
|
129
|
-
* @param {!IThenable<!Session>} session
|
130
|
-
* @param {...?} rest
|
131
|
-
*/
|
132
|
-
constructor(session, ...rest) {
|
133
|
-
super(session, ...rest)
|
134
|
-
|
135
|
-
const pd = this.getSession().then((session) => {
|
136
|
-
return new ctor(session, ...rest)
|
137
|
-
})
|
138
|
-
|
139
|
-
/** @override */
|
140
|
-
this.then = pd.then.bind(pd)
|
141
|
-
|
142
|
-
/** @override */
|
143
|
-
this.catch = pd.catch.bind(pd)
|
144
|
-
}
|
145
|
-
}
|
146
|
-
THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy)
|
147
|
-
}
|
148
|
-
return thenableWebDriverProxy.createSession(...args)
|
149
|
-
}
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Creates new {@link webdriver.WebDriver WebDriver} instances. The environment
|
153
|
-
* variables listed below may be used to override a builder's configuration,
|
154
|
-
* allowing quick runtime changes.
|
155
|
-
*
|
156
|
-
* - {@code SELENIUM_BROWSER}: defines the target browser in the form
|
157
|
-
* {@code browser[:version][:platform]}.
|
158
|
-
*
|
159
|
-
* - {@code SELENIUM_REMOTE_URL}: defines the remote URL for all builder
|
160
|
-
* instances. This environment variable should be set to a fully qualified
|
161
|
-
* URL for a WebDriver server (e.g. http://localhost:4444/wd/hub). This
|
162
|
-
* option always takes precedence over {@code SELENIUM_SERVER_JAR}.
|
163
|
-
*
|
164
|
-
* - {@code SELENIUM_SERVER_JAR}: defines the path to the
|
165
|
-
* <a href="http://selenium-release.storage.googleapis.com/index.html">
|
166
|
-
* standalone Selenium server</a> jar to use. The server will be started the
|
167
|
-
* first time a WebDriver instance and be killed when the process exits.
|
168
|
-
*
|
169
|
-
* Suppose you had mytest.js that created WebDriver with
|
170
|
-
*
|
171
|
-
* var driver = new webdriver.Builder()
|
172
|
-
* .forBrowser('chrome')
|
173
|
-
* .build();
|
174
|
-
*
|
175
|
-
* This test could be made to use Firefox on the local machine by running with
|
176
|
-
* `SELENIUM_BROWSER=firefox node mytest.js`. Rather than change the code to
|
177
|
-
* target Google Chrome on a remote machine, you can simply set the
|
178
|
-
* `SELENIUM_BROWSER` and `SELENIUM_REMOTE_URL` environment variables:
|
179
|
-
*
|
180
|
-
* SELENIUM_BROWSER=chrome:36:LINUX \
|
181
|
-
* SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
|
182
|
-
* node mytest.js
|
183
|
-
*
|
184
|
-
* You could also use a local copy of the standalone Selenium server:
|
185
|
-
*
|
186
|
-
* SELENIUM_BROWSER=chrome:36:LINUX \
|
187
|
-
* SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
|
188
|
-
* node mytest.js
|
189
|
-
*/
|
190
|
-
class Builder {
|
191
|
-
constructor() {
|
192
|
-
/** @private @const */
|
193
|
-
this.log_ = logging.getLogger('webdriver.Builder')
|
194
|
-
|
195
|
-
/** @private {string} */
|
196
|
-
this.url_ = ''
|
197
|
-
|
198
|
-
/** @private {?string} */
|
199
|
-
this.proxy_ = null
|
200
|
-
|
201
|
-
/** @private {!Capabilities} */
|
202
|
-
this.capabilities_ = new Capabilities()
|
203
|
-
|
204
|
-
/** @private {chrome.Options} */
|
205
|
-
this.chromeOptions_ = null
|
206
|
-
|
207
|
-
/** @private {chrome.ServiceBuilder} */
|
208
|
-
this.chromeService_ = null
|
209
|
-
|
210
|
-
/** @private {firefox.Options} */
|
211
|
-
this.firefoxOptions_ = null
|
212
|
-
|
213
|
-
/** @private {firefox.ServiceBuilder} */
|
214
|
-
this.firefoxService_ = null
|
215
|
-
|
216
|
-
/** @private {ie.Options} */
|
217
|
-
this.ieOptions_ = null
|
218
|
-
|
219
|
-
/** @private {ie.ServiceBuilder} */
|
220
|
-
this.ieService_ = null
|
221
|
-
|
222
|
-
/** @private {safari.Options} */
|
223
|
-
this.safariOptions_ = null
|
224
|
-
|
225
|
-
/** @private {edge.Options} */
|
226
|
-
this.edgeOptions_ = null
|
227
|
-
|
228
|
-
/** @private {remote.DriverService.Builder} */
|
229
|
-
this.edgeService_ = null
|
230
|
-
|
231
|
-
/** @private {boolean} */
|
232
|
-
this.ignoreEnv_ = false
|
233
|
-
|
234
|
-
/** @private {http.Agent} */
|
235
|
-
this.agent_ = null
|
236
|
-
|
237
|
-
/** @private {opera.Options} */
|
238
|
-
this.operaOptions_ = null
|
239
|
-
|
240
|
-
/** @private {remote.DriverService.Builder} */
|
241
|
-
this.operaService_ = null
|
242
|
-
}
|
243
|
-
|
244
|
-
/**
|
245
|
-
* Configures this builder to ignore any environment variable overrides and to
|
246
|
-
* only use the configuration specified through this instance's API.
|
247
|
-
*
|
248
|
-
* @return {!Builder} A self reference.
|
249
|
-
*/
|
250
|
-
disableEnvironmentOverrides() {
|
251
|
-
this.ignoreEnv_ = true
|
252
|
-
return this
|
253
|
-
}
|
254
|
-
|
255
|
-
/**
|
256
|
-
* Sets the URL of a remote WebDriver server to use. Once a remote URL has
|
257
|
-
* been specified, the builder direct all new clients to that server. If this
|
258
|
-
* method is never called, the Builder will attempt to create all clients
|
259
|
-
* locally.
|
260
|
-
*
|
261
|
-
* As an alternative to this method, you may also set the
|
262
|
-
* `SELENIUM_REMOTE_URL` environment variable.
|
263
|
-
*
|
264
|
-
* @param {string} url The URL of a remote server to use.
|
265
|
-
* @return {!Builder} A self reference.
|
266
|
-
*/
|
267
|
-
usingServer(url) {
|
268
|
-
this.url_ = url
|
269
|
-
return this
|
270
|
-
}
|
271
|
-
|
272
|
-
/**
|
273
|
-
* @return {string} The URL of the WebDriver server this instance is
|
274
|
-
* configured to use.
|
275
|
-
*/
|
276
|
-
getServerUrl() {
|
277
|
-
return this.url_
|
278
|
-
}
|
279
|
-
|
280
|
-
/**
|
281
|
-
* Sets the URL of the proxy to use for the WebDriver's HTTP connections.
|
282
|
-
* If this method is never called, the Builder will create a connection
|
283
|
-
* without a proxy.
|
284
|
-
*
|
285
|
-
* @param {string} proxy The URL of a proxy to use.
|
286
|
-
* @return {!Builder} A self reference.
|
287
|
-
*/
|
288
|
-
usingWebDriverProxy(proxy) {
|
289
|
-
this.proxy_ = proxy
|
290
|
-
return this
|
291
|
-
}
|
292
|
-
|
293
|
-
/**
|
294
|
-
* @return {?string} The URL of the proxy server to use for the WebDriver's
|
295
|
-
* HTTP connections, or `null` if not set.
|
296
|
-
*/
|
297
|
-
getWebDriverProxy() {
|
298
|
-
return this.proxy_
|
299
|
-
}
|
300
|
-
|
301
|
-
/**
|
302
|
-
* Sets the http agent to use for each request.
|
303
|
-
* If this method is not called, the Builder will use http.globalAgent by default.
|
304
|
-
*
|
305
|
-
* @param {http.Agent} agent The agent to use for each request.
|
306
|
-
* @return {!Builder} A self reference.
|
307
|
-
*/
|
308
|
-
usingHttpAgent(agent) {
|
309
|
-
this.agent_ = agent
|
310
|
-
return this
|
311
|
-
}
|
312
|
-
|
313
|
-
/**
|
314
|
-
* @return {http.Agent} The http agent used for each request
|
315
|
-
*/
|
316
|
-
getHttpAgent() {
|
317
|
-
return this.agent_
|
318
|
-
}
|
319
|
-
|
320
|
-
/**
|
321
|
-
* Sets the desired capabilities when requesting a new session. This will
|
322
|
-
* overwrite any previously set capabilities.
|
323
|
-
* @param {!(Object|Capabilities)} capabilities The desired capabilities for
|
324
|
-
* a new session.
|
325
|
-
* @return {!Builder} A self reference.
|
326
|
-
*/
|
327
|
-
withCapabilities(capabilities) {
|
328
|
-
this.capabilities_ = new Capabilities(capabilities)
|
329
|
-
return this
|
330
|
-
}
|
331
|
-
|
332
|
-
/**
|
333
|
-
* Returns the base set of capabilities this instance is currently configured
|
334
|
-
* to use.
|
335
|
-
* @return {!Capabilities} The current capabilities for this builder.
|
336
|
-
*/
|
337
|
-
getCapabilities() {
|
338
|
-
return this.capabilities_
|
339
|
-
}
|
340
|
-
|
341
|
-
/**
|
342
|
-
* Configures the target browser for clients created by this instance.
|
343
|
-
* Any calls to {@link #withCapabilities} after this function will
|
344
|
-
* overwrite these settings.
|
345
|
-
*
|
346
|
-
* You may also define the target browser using the {@code SELENIUM_BROWSER}
|
347
|
-
* environment variable. If set, this environment variable should be of the
|
348
|
-
* form `browser[:[version][:platform]]`.
|
349
|
-
*
|
350
|
-
* @param {(string|!Browser)} name The name of the target browser;
|
351
|
-
* common defaults are available on the {@link webdriver.Browser} enum.
|
352
|
-
* @param {string=} opt_version A desired version; may be omitted if any
|
353
|
-
* version should be used.
|
354
|
-
* @param {(string|!capabilities.Platform)=} opt_platform
|
355
|
-
* The desired platform; may be omitted if any platform may be used.
|
356
|
-
* @return {!Builder} A self reference.
|
357
|
-
*/
|
358
|
-
forBrowser(name, opt_version, opt_platform) {
|
359
|
-
this.capabilities_.setBrowserName(name)
|
360
|
-
if (opt_version) {
|
361
|
-
this.capabilities_.setBrowserVersion(opt_version)
|
362
|
-
}
|
363
|
-
if (opt_platform) {
|
364
|
-
this.capabilities_.setPlatform(opt_platform)
|
365
|
-
}
|
366
|
-
return this
|
367
|
-
}
|
368
|
-
|
369
|
-
/**
|
370
|
-
* Sets the proxy configuration for the target browser.
|
371
|
-
* Any calls to {@link #withCapabilities} after this function will
|
372
|
-
* overwrite these settings.
|
373
|
-
*
|
374
|
-
* @param {!./lib/proxy.Config} config The configuration to use.
|
375
|
-
* @return {!Builder} A self reference.
|
376
|
-
*/
|
377
|
-
setProxy(config) {
|
378
|
-
this.capabilities_.setProxy(config)
|
379
|
-
return this
|
380
|
-
}
|
381
|
-
|
382
|
-
/**
|
383
|
-
* Sets the logging preferences for the created session. Preferences may be
|
384
|
-
* changed by repeated calls, or by calling {@link #withCapabilities}.
|
385
|
-
* @param {!(./lib/logging.Preferences|Object<string, string>)} prefs The
|
386
|
-
* desired logging preferences.
|
387
|
-
* @return {!Builder} A self reference.
|
388
|
-
*/
|
389
|
-
setLoggingPrefs(prefs) {
|
390
|
-
this.capabilities_.setLoggingPrefs(prefs)
|
391
|
-
return this
|
392
|
-
}
|
393
|
-
|
394
|
-
/**
|
395
|
-
* Sets the default action to take with an unexpected alert before returning
|
396
|
-
* an error.
|
397
|
-
*
|
398
|
-
* @param {?capabilities.UserPromptHandler} behavior The desired behavior.
|
399
|
-
* @return {!Builder} A self reference.
|
400
|
-
* @see capabilities.Capabilities#setAlertBehavior
|
401
|
-
*/
|
402
|
-
setAlertBehavior(behavior) {
|
403
|
-
this.capabilities_.setAlertBehavior(behavior)
|
404
|
-
return this
|
405
|
-
}
|
406
|
-
|
407
|
-
/**
|
408
|
-
* Sets Chrome specific {@linkplain chrome.Options options} for drivers
|
409
|
-
* created by this builder. Any logging or proxy settings defined on the given
|
410
|
-
* options will take precedence over those set through
|
411
|
-
* {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
|
412
|
-
*
|
413
|
-
* @param {!chrome.Options} options The ChromeDriver options to use.
|
414
|
-
* @return {!Builder} A self reference.
|
415
|
-
*/
|
416
|
-
setChromeOptions(options) {
|
417
|
-
this.chromeOptions_ = options
|
418
|
-
return this
|
419
|
-
}
|
420
|
-
|
421
|
-
/**
|
422
|
-
* Sets Opera specific {@linkplain opera.Options options} for drivers
|
423
|
-
* created by this builder. Any logging or proxy settings defined on the given
|
424
|
-
* options will take precedence over those set through
|
425
|
-
* {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
|
426
|
-
*
|
427
|
-
* @param {!opera.Options} options The OperaDriver options to use.
|
428
|
-
* @return {!Builder} A self reference.
|
429
|
-
*/
|
430
|
-
setOperaOptions(options) {
|
431
|
-
this.operaOptions_ = options
|
432
|
-
return this
|
433
|
-
}
|
434
|
-
|
435
|
-
/**
|
436
|
-
* @return {chrome.Options} the Chrome specific options currently configured
|
437
|
-
* for this builder.
|
438
|
-
*/
|
439
|
-
getChromeOptions() {
|
440
|
-
return this.chromeOptions_
|
441
|
-
}
|
442
|
-
|
443
|
-
/**
|
444
|
-
* Sets the service builder to use for managing the chromedriver child process
|
445
|
-
* when creating new Chrome sessions.
|
446
|
-
*
|
447
|
-
* @param {chrome.ServiceBuilder} service the service to use.
|
448
|
-
* @return {!Builder} A self reference.
|
449
|
-
*/
|
450
|
-
setChromeService(service) {
|
451
|
-
if (service && !(service instanceof chrome.ServiceBuilder)) {
|
452
|
-
throw TypeError('not a chrome.ServiceBuilder object')
|
453
|
-
}
|
454
|
-
this.chromeService_ = service
|
455
|
-
return this
|
456
|
-
}
|
457
|
-
|
458
|
-
/**
|
459
|
-
* Sets Firefox specific {@linkplain firefox.Options options} for drivers
|
460
|
-
* created by this builder. Any logging or proxy settings defined on the given
|
461
|
-
* options will take precedence over those set through
|
462
|
-
* {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
|
463
|
-
*
|
464
|
-
* @param {!firefox.Options} options The FirefoxDriver options to use.
|
465
|
-
* @return {!Builder} A self reference.
|
466
|
-
*/
|
467
|
-
setFirefoxOptions(options) {
|
468
|
-
this.firefoxOptions_ = options
|
469
|
-
return this
|
470
|
-
}
|
471
|
-
|
472
|
-
/**
|
473
|
-
* @return {firefox.Options} the Firefox specific options currently configured
|
474
|
-
* for this instance.
|
475
|
-
*/
|
476
|
-
getFirefoxOptions() {
|
477
|
-
return this.firefoxOptions_
|
478
|
-
}
|
479
|
-
|
480
|
-
/**
|
481
|
-
* Sets the {@link firefox.ServiceBuilder} to use to manage the geckodriver
|
482
|
-
* child process when creating Firefox sessions locally.
|
483
|
-
*
|
484
|
-
* @param {firefox.ServiceBuilder} service the service to use.
|
485
|
-
* @return {!Builder} a self reference.
|
486
|
-
*/
|
487
|
-
setFirefoxService(service) {
|
488
|
-
if (service && !(service instanceof firefox.ServiceBuilder)) {
|
489
|
-
throw TypeError('not a firefox.ServiceBuilder object')
|
490
|
-
}
|
491
|
-
this.firefoxService_ = service
|
492
|
-
return this
|
493
|
-
}
|
494
|
-
|
495
|
-
/**
|
496
|
-
* Set Internet Explorer specific {@linkplain ie.Options options} for drivers
|
497
|
-
* created by this builder. Any proxy settings defined on the given options
|
498
|
-
* will take precedence over those set through {@link #setProxy}.
|
499
|
-
*
|
500
|
-
* @param {!ie.Options} options The IEDriver options to use.
|
501
|
-
* @return {!Builder} A self reference.
|
502
|
-
*/
|
503
|
-
setIeOptions(options) {
|
504
|
-
this.ieOptions_ = options
|
505
|
-
return this
|
506
|
-
}
|
507
|
-
|
508
|
-
/**
|
509
|
-
* Sets the {@link ie.ServiceBuilder} to use to manage the geckodriver
|
510
|
-
* child process when creating IE sessions locally.
|
511
|
-
*
|
512
|
-
* @param {ie.ServiceBuilder} service the service to use.
|
513
|
-
* @return {!Builder} a self reference.
|
514
|
-
*/
|
515
|
-
setIeService(service) {
|
516
|
-
this.ieService_ = service
|
517
|
-
return this
|
518
|
-
}
|
519
|
-
|
520
|
-
/**
|
521
|
-
* Set {@linkplain edge.Options options} specific to Microsoft's Edge browser
|
522
|
-
* for drivers created by this builder. Any proxy settings defined on the
|
523
|
-
* given options will take precedence over those set through
|
524
|
-
* {@link #setProxy}.
|
525
|
-
*
|
526
|
-
* @param {!edge.Options} options The MicrosoftEdgeDriver options to use.
|
527
|
-
* @return {!Builder} A self reference.
|
528
|
-
*/
|
529
|
-
setEdgeOptions(options) {
|
530
|
-
this.edgeOptions_ = options
|
531
|
-
return this
|
532
|
-
}
|
533
|
-
|
534
|
-
/**
|
535
|
-
* Sets the {@link edge.ServiceBuilder} to use to manage the
|
536
|
-
* MicrosoftEdgeDriver child process when creating sessions locally.
|
537
|
-
*
|
538
|
-
* @param {edge.ServiceBuilder} service the service to use.
|
539
|
-
* @return {!Builder} a self reference.
|
540
|
-
*/
|
541
|
-
setEdgeService(service) {
|
542
|
-
if (service && !(service instanceof edge.ServiceBuilder)) {
|
543
|
-
throw TypeError('not a edge.ServiceBuilder object')
|
544
|
-
}
|
545
|
-
this.edgeService_ = service
|
546
|
-
return this
|
547
|
-
}
|
548
|
-
|
549
|
-
/**
|
550
|
-
* Sets the {@link opera.ServiceBuilder} to use to manage the
|
551
|
-
* operaDriver child process when creating sessions locally.
|
552
|
-
*
|
553
|
-
* @param {opera.ServiceBuilder} service the service to use.
|
554
|
-
* @return {!Builder} a self reference.
|
555
|
-
*/
|
556
|
-
setOperaService(service) {
|
557
|
-
if (service && !(service instanceof opera.ServiceBuilder)) {
|
558
|
-
throw TypeError('not a opera.ServiceBuilder object')
|
559
|
-
}
|
560
|
-
this.operaService_ = service
|
561
|
-
return this
|
562
|
-
}
|
563
|
-
|
564
|
-
/**
|
565
|
-
* Sets Safari specific {@linkplain safari.Options options} for drivers
|
566
|
-
* created by this builder. Any logging settings defined on the given options
|
567
|
-
* will take precedence over those set through {@link #setLoggingPrefs}.
|
568
|
-
*
|
569
|
-
* @param {!safari.Options} options The Safari options to use.
|
570
|
-
* @return {!Builder} A self reference.
|
571
|
-
*/
|
572
|
-
setSafariOptions(options) {
|
573
|
-
this.safariOptions_ = options
|
574
|
-
return this
|
575
|
-
}
|
576
|
-
|
577
|
-
/**
|
578
|
-
* @return {safari.Options} the Safari specific options currently configured
|
579
|
-
* for this instance.
|
580
|
-
*/
|
581
|
-
getSafariOptions() {
|
582
|
-
return this.safariOptions_
|
583
|
-
}
|
584
|
-
|
585
|
-
/**
|
586
|
-
* Creates a new WebDriver client based on this builder's current
|
587
|
-
* configuration.
|
588
|
-
*
|
589
|
-
* This method will return a {@linkplain ThenableWebDriver} instance, allowing
|
590
|
-
* users to issue commands directly without calling `then()`. The returned
|
591
|
-
* thenable wraps a promise that will resolve to a concrete
|
592
|
-
* {@linkplain webdriver.WebDriver WebDriver} instance. The promise will be
|
593
|
-
* rejected if the remote end fails to create a new session.
|
594
|
-
*
|
595
|
-
* @return {!ThenableWebDriver} A new WebDriver instance.
|
596
|
-
* @throws {Error} If the current configuration is invalid.
|
597
|
-
*/
|
598
|
-
build() {
|
599
|
-
// Create a copy for any changes we may need to make based on the current
|
600
|
-
// environment.
|
601
|
-
const capabilities = new Capabilities(this.capabilities_)
|
602
|
-
|
603
|
-
let browser
|
604
|
-
if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
|
605
|
-
this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`)
|
606
|
-
browser = process.env.SELENIUM_BROWSER.split(/:/, 3)
|
607
|
-
capabilities.setBrowserName(browser[0])
|
608
|
-
|
609
|
-
browser[1] && capabilities.setBrowserVersion(browser[1])
|
610
|
-
browser[2] && capabilities.setPlatform(browser[2])
|
611
|
-
}
|
612
|
-
|
613
|
-
browser = capabilities.get(Capability.BROWSER_NAME)
|
614
|
-
|
615
|
-
if (typeof browser !== 'string') {
|
616
|
-
throw TypeError(
|
617
|
-
`Target browser must be a string, but is <${typeof browser}>;` +
|
618
|
-
' did you forget to call forBrowser()?'
|
619
|
-
)
|
620
|
-
}
|
621
|
-
|
622
|
-
if (browser === 'ie') {
|
623
|
-
browser = Browser.INTERNET_EXPLORER
|
624
|
-
}
|
625
|
-
|
626
|
-
// Apply browser specific overrides.
|
627
|
-
if (browser === Browser.CHROME && this.chromeOptions_) {
|
628
|
-
capabilities.merge(this.chromeOptions_)
|
629
|
-
} else if (browser === Browser.FIREFOX && this.firefoxOptions_) {
|
630
|
-
capabilities.merge(this.firefoxOptions_)
|
631
|
-
} else if (browser === Browser.INTERNET_EXPLORER && this.ieOptions_) {
|
632
|
-
capabilities.merge(this.ieOptions_)
|
633
|
-
} else if (browser === Browser.SAFARI && this.safariOptions_) {
|
634
|
-
capabilities.merge(this.safariOptions_)
|
635
|
-
} else if (browser === Browser.EDGE && this.edgeOptions_) {
|
636
|
-
capabilities.merge(this.edgeOptions_)
|
637
|
-
} else if (browser === Browser.OPERA && this.operaOptions_) {
|
638
|
-
capabilities.merge(this.operaOptions_)
|
639
|
-
}
|
640
|
-
|
641
|
-
checkOptions(
|
642
|
-
capabilities,
|
643
|
-
'chromeOptions',
|
644
|
-
chrome.Options,
|
645
|
-
'setChromeOptions'
|
646
|
-
)
|
647
|
-
checkOptions(
|
648
|
-
capabilities,
|
649
|
-
'moz:firefoxOptions',
|
650
|
-
firefox.Options,
|
651
|
-
'setFirefoxOptions'
|
652
|
-
)
|
653
|
-
checkOptions(
|
654
|
-
capabilities,
|
655
|
-
'safari.options',
|
656
|
-
safari.Options,
|
657
|
-
'setSafariOptions'
|
658
|
-
)
|
659
|
-
|
660
|
-
// Check for a remote browser.
|
661
|
-
let url = this.url_
|
662
|
-
if (!this.ignoreEnv_) {
|
663
|
-
if (process.env.SELENIUM_REMOTE_URL) {
|
664
|
-
this.log_.fine(`SELENIUM_REMOTE_URL=${process.env.SELENIUM_REMOTE_URL}`)
|
665
|
-
url = process.env.SELENIUM_REMOTE_URL
|
666
|
-
} else if (process.env.SELENIUM_SERVER_JAR) {
|
667
|
-
this.log_.fine(`SELENIUM_SERVER_JAR=${process.env.SELENIUM_SERVER_JAR}`)
|
668
|
-
url = startSeleniumServer(process.env.SELENIUM_SERVER_JAR)
|
669
|
-
}
|
670
|
-
}
|
671
|
-
|
672
|
-
if (url) {
|
673
|
-
this.log_.fine('Creating session on remote server')
|
674
|
-
let client = Promise.resolve(url).then(
|
675
|
-
(url) => new _http.HttpClient(url, this.agent_, this.proxy_)
|
676
|
-
)
|
677
|
-
let executor = new _http.Executor(client)
|
678
|
-
|
679
|
-
if (browser === Browser.CHROME) {
|
680
|
-
const driver = ensureFileDetectorsAreEnabled(chrome.Driver)
|
681
|
-
return createDriver(driver, capabilities, executor)
|
682
|
-
}
|
683
|
-
|
684
|
-
if (browser === Browser.FIREFOX) {
|
685
|
-
const driver = ensureFileDetectorsAreEnabled(firefox.Driver)
|
686
|
-
return createDriver(driver, capabilities, executor)
|
687
|
-
}
|
688
|
-
return createDriver(WebDriver, executor, capabilities)
|
689
|
-
}
|
690
|
-
|
691
|
-
// Check for a native browser.
|
692
|
-
switch (browser) {
|
693
|
-
case Browser.CHROME: {
|
694
|
-
let service = null
|
695
|
-
if (this.chromeService_) {
|
696
|
-
service = this.chromeService_.build()
|
697
|
-
}
|
698
|
-
return createDriver(chrome.Driver, capabilities, service)
|
699
|
-
}
|
700
|
-
|
701
|
-
case Browser.FIREFOX: {
|
702
|
-
let service = null
|
703
|
-
if (this.firefoxService_) {
|
704
|
-
service = this.firefoxService_.build()
|
705
|
-
}
|
706
|
-
return createDriver(firefox.Driver, capabilities, service)
|
707
|
-
}
|
708
|
-
|
709
|
-
case Browser.INTERNET_EXPLORER: {
|
710
|
-
let service = null
|
711
|
-
if (this.ieService_) {
|
712
|
-
service = this.ieService_.build()
|
713
|
-
}
|
714
|
-
return createDriver(ie.Driver, capabilities, service)
|
715
|
-
}
|
716
|
-
|
717
|
-
case Browser.EDGE: {
|
718
|
-
let service = null
|
719
|
-
if (this.edgeService_) {
|
720
|
-
service = this.edgeService_.build()
|
721
|
-
}
|
722
|
-
return createDriver(edge.Driver, capabilities, service)
|
723
|
-
}
|
724
|
-
|
725
|
-
case Browser.OPERA: {
|
726
|
-
let service = null
|
727
|
-
if (this.operaService_) {
|
728
|
-
service = this.operaService_.build()
|
729
|
-
}
|
730
|
-
return createDriver(opera.Driver, capabilities, service)
|
731
|
-
}
|
732
|
-
|
733
|
-
case Browser.SAFARI:
|
734
|
-
return createDriver(safari.Driver, capabilities)
|
735
|
-
|
736
|
-
default:
|
737
|
-
throw new Error(
|
738
|
-
'Do not know how to build driver: ' +
|
739
|
-
browser +
|
740
|
-
'; did you forget to call usingServer(url)?'
|
741
|
-
)
|
742
|
-
}
|
743
|
-
}
|
744
|
-
}
|
745
|
-
|
746
|
-
/**
|
747
|
-
* In the 3.x releases, the various browser option classes
|
748
|
-
* (e.g. firefox.Options) had to be manually set as an option using the
|
749
|
-
* Capabilties class:
|
750
|
-
*
|
751
|
-
* let ffo = new firefox.Options();
|
752
|
-
* // Configure firefox options...
|
753
|
-
*
|
754
|
-
* let caps = new Capabilities();
|
755
|
-
* caps.set('moz:firefoxOptions', ffo);
|
756
|
-
*
|
757
|
-
* let driver = new Builder()
|
758
|
-
* .withCapabilities(caps)
|
759
|
-
* .build();
|
760
|
-
*
|
761
|
-
* The options are now subclasses of Capabilities and can be used directly. A
|
762
|
-
* direct translation of the above is:
|
763
|
-
*
|
764
|
-
* let ffo = new firefox.Options();
|
765
|
-
* // Configure firefox options...
|
766
|
-
*
|
767
|
-
* let driver = new Builder()
|
768
|
-
* .withCapabilities(ffo)
|
769
|
-
* .build();
|
770
|
-
*
|
771
|
-
* You can also set the options for various browsers at once and let the builder
|
772
|
-
* choose the correct set at runtime (see Builder docs above):
|
773
|
-
*
|
774
|
-
* let ffo = new firefox.Options();
|
775
|
-
* // Configure ...
|
776
|
-
*
|
777
|
-
* let co = new chrome.Options();
|
778
|
-
* // Configure ...
|
779
|
-
*
|
780
|
-
* let driver = new Builder()
|
781
|
-
* .setChromeOptions(co)
|
782
|
-
* .setFirefoxOptions(ffo)
|
783
|
-
* .build();
|
784
|
-
*
|
785
|
-
* @param {!Capabilities} caps
|
786
|
-
* @param {string} key
|
787
|
-
* @param {function(new: Capabilities)} optionType
|
788
|
-
* @param {string} setMethod
|
789
|
-
* @throws {error.InvalidArgumentError}
|
790
|
-
*/
|
791
|
-
function checkOptions(caps, key, optionType, setMethod) {
|
792
|
-
let val = caps.get(key)
|
793
|
-
if (val instanceof optionType) {
|
794
|
-
throw new error.InvalidArgumentError(
|
795
|
-
'Options class extends Capabilities and should not be set as key ' +
|
796
|
-
`"${key}"; set browser-specific options with ` +
|
797
|
-
`Builder.${setMethod}(). For more information, see the ` +
|
798
|
-
'documentation attached to the function that threw this error'
|
799
|
-
)
|
800
|
-
}
|
801
|
-
}
|
802
|
-
|
803
|
-
// PUBLIC API
|
804
|
-
|
805
|
-
exports.Browser = capabilities.Browser
|
806
|
-
exports.Builder = Builder
|
807
|
-
exports.Button = input.Button
|
808
|
-
exports.By = by.By
|
809
|
-
exports.withTagName = by.withTagName
|
810
|
-
exports.Capabilities = capabilities.Capabilities
|
811
|
-
exports.Capability = capabilities.Capability
|
812
|
-
exports.Condition = webdriver.Condition
|
813
|
-
exports.FileDetector = input.FileDetector
|
814
|
-
exports.Key = input.Key
|
815
|
-
exports.Origin = input.Origin
|
816
|
-
exports.Session = session.Session
|
817
|
-
exports.ThenableWebDriver = ThenableWebDriver
|
818
|
-
exports.WebDriver = webdriver.WebDriver
|
819
|
-
exports.WebElement = webdriver.WebElement
|
820
|
-
exports.WebElementCondition = webdriver.WebElementCondition
|
821
|
-
exports.WebElementPromise = webdriver.WebElementPromise
|
822
|
-
exports.error = error
|
823
|
-
exports.logging = logging
|
824
|
-
exports.promise = promise
|
825
|
-
exports.until = until
|