UrgentcareCLI 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +60 -25
- data/Notes +1 -1
- data/README.md +5 -5
- data/Rakefile +2 -0
- data/UrgentCare.gemspec +3 -3
- data/background.jpg +0 -0
- data/lib/UrgentCare.rb +3 -0
- data/lib/UrgentCare/CLI.rb +6 -2
- data/lib/UrgentCare/version.rb +1 -1
- data/lib/Urgentcare/Scraper.rb +65 -23
- data/node_modules/.bin/rimraf +1 -0
- data/node_modules/.package-lock.json +250 -0
- data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
- data/node_modules/balanced-match/LICENSE.md +21 -0
- data/node_modules/balanced-match/README.md +97 -0
- data/node_modules/balanced-match/index.js +62 -0
- data/node_modules/balanced-match/package.json +48 -0
- data/node_modules/brace-expansion/LICENSE +21 -0
- data/node_modules/brace-expansion/README.md +129 -0
- data/node_modules/brace-expansion/index.js +201 -0
- data/node_modules/brace-expansion/package.json +47 -0
- data/node_modules/concat-map/.travis.yml +4 -0
- data/node_modules/concat-map/LICENSE +18 -0
- data/node_modules/concat-map/README.markdown +62 -0
- data/node_modules/concat-map/example/map.js +6 -0
- data/node_modules/concat-map/index.js +13 -0
- data/node_modules/concat-map/package.json +43 -0
- data/node_modules/concat-map/test/map.js +39 -0
- data/node_modules/core-util-is/LICENSE +19 -0
- data/node_modules/core-util-is/README.md +3 -0
- data/node_modules/core-util-is/float.patch +604 -0
- data/node_modules/core-util-is/lib/util.js +107 -0
- data/node_modules/core-util-is/package.json +32 -0
- data/node_modules/core-util-is/test.js +68 -0
- data/node_modules/fs.realpath/LICENSE +43 -0
- data/node_modules/fs.realpath/README.md +33 -0
- data/node_modules/fs.realpath/index.js +66 -0
- data/node_modules/fs.realpath/old.js +303 -0
- data/node_modules/fs.realpath/package.json +26 -0
- data/node_modules/glob/LICENSE +21 -0
- data/node_modules/glob/README.md +375 -0
- data/node_modules/glob/changelog.md +67 -0
- data/node_modules/glob/common.js +234 -0
- data/node_modules/glob/glob.js +788 -0
- data/node_modules/glob/package.json +51 -0
- data/node_modules/glob/sync.js +484 -0
- data/node_modules/immediate/LICENSE.txt +20 -0
- data/node_modules/immediate/README.md +93 -0
- data/node_modules/immediate/dist/immediate.js +75 -0
- data/node_modules/immediate/dist/immediate.min.js +1 -0
- data/node_modules/immediate/lib/browser.js +69 -0
- data/node_modules/immediate/lib/index.js +73 -0
- data/node_modules/immediate/package.json +42 -0
- data/node_modules/inflight/LICENSE +15 -0
- data/node_modules/inflight/README.md +37 -0
- data/node_modules/inflight/inflight.js +54 -0
- data/node_modules/inflight/package.json +29 -0
- data/node_modules/inherits/LICENSE +16 -0
- data/node_modules/inherits/README.md +42 -0
- data/node_modules/inherits/inherits.js +9 -0
- data/node_modules/inherits/inherits_browser.js +27 -0
- data/node_modules/inherits/package.json +29 -0
- data/node_modules/isarray/.npmignore +1 -0
- data/node_modules/isarray/.travis.yml +4 -0
- data/node_modules/isarray/Makefile +6 -0
- data/node_modules/isarray/README.md +60 -0
- data/node_modules/isarray/component.json +19 -0
- data/node_modules/isarray/index.js +5 -0
- data/node_modules/isarray/package.json +45 -0
- data/node_modules/isarray/test.js +20 -0
- data/node_modules/jszip/.codeclimate.yml +16 -0
- data/node_modules/jszip/.editorconfig +8 -0
- data/node_modules/jszip/.jshintignore +1 -0
- data/node_modules/jszip/.jshintrc +21 -0
- data/node_modules/jszip/.travis.yml +17 -0
- data/node_modules/jszip/CHANGES.md +163 -0
- data/node_modules/jszip/LICENSE.markdown +651 -0
- data/node_modules/jszip/README.markdown +35 -0
- data/node_modules/jszip/dist/jszip.js +30 -0
- data/node_modules/jszip/dist/jszip.min.js +13 -0
- data/node_modules/jszip/index.d.ts +270 -0
- data/node_modules/jszip/lib/base64.js +106 -0
- data/node_modules/jszip/lib/compressedObject.js +74 -0
- data/node_modules/jszip/lib/compressions.js +14 -0
- data/node_modules/jszip/lib/crc32.js +77 -0
- data/node_modules/jszip/lib/defaults.js +11 -0
- data/node_modules/jszip/lib/external.js +19 -0
- data/node_modules/jszip/lib/flate.js +85 -0
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
- data/node_modules/jszip/lib/generate/index.js +57 -0
- data/node_modules/jszip/lib/index.js +52 -0
- data/node_modules/jszip/lib/license_header.js +11 -0
- data/node_modules/jszip/lib/load.js +81 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- data/node_modules/jszip/lib/nodejsUtils.js +57 -0
- data/node_modules/jszip/lib/object.js +389 -0
- data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
- data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- data/node_modules/jszip/lib/reader/DataReader.js +116 -0
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- data/node_modules/jszip/lib/reader/StringReader.js +38 -0
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- data/node_modules/jszip/lib/reader/readerFor.js +28 -0
- data/node_modules/jszip/lib/signature.js +7 -0
- data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
- data/node_modules/jszip/lib/support.js +38 -0
- data/node_modules/jszip/lib/utf8.js +275 -0
- data/node_modules/jszip/lib/utils.js +476 -0
- data/node_modules/jszip/lib/zipEntries.js +262 -0
- data/node_modules/jszip/lib/zipEntry.js +294 -0
- data/node_modules/jszip/lib/zipObject.js +133 -0
- data/node_modules/jszip/package.json +63 -0
- data/node_modules/jszip/vendor/FileSaver.js +247 -0
- data/node_modules/lie/README.md +62 -0
- data/node_modules/lie/dist/lie.js +350 -0
- data/node_modules/lie/dist/lie.min.js +1 -0
- data/node_modules/lie/dist/lie.polyfill.js +358 -0
- data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- data/node_modules/lie/lib/browser.js +273 -0
- data/node_modules/lie/lib/index.js +298 -0
- data/node_modules/lie/license.md +7 -0
- data/node_modules/lie/lie.d.ts +244 -0
- data/node_modules/lie/package.json +69 -0
- data/node_modules/lie/polyfill.js +4 -0
- data/node_modules/minimatch/LICENSE +15 -0
- data/node_modules/minimatch/README.md +209 -0
- data/node_modules/minimatch/minimatch.js +923 -0
- data/node_modules/minimatch/package.json +30 -0
- data/node_modules/once/LICENSE +15 -0
- data/node_modules/once/README.md +79 -0
- data/node_modules/once/once.js +42 -0
- data/node_modules/once/package.json +33 -0
- data/node_modules/pako/CHANGELOG.md +164 -0
- data/node_modules/pako/LICENSE +21 -0
- data/node_modules/pako/README.md +191 -0
- data/node_modules/pako/dist/pako.js +6818 -0
- data/node_modules/pako/dist/pako.min.js +1 -0
- data/node_modules/pako/dist/pako_deflate.js +3997 -0
- data/node_modules/pako/dist/pako_deflate.min.js +1 -0
- data/node_modules/pako/dist/pako_inflate.js +3300 -0
- data/node_modules/pako/dist/pako_inflate.min.js +1 -0
- data/node_modules/pako/index.js +14 -0
- data/node_modules/pako/lib/deflate.js +400 -0
- data/node_modules/pako/lib/inflate.js +423 -0
- data/node_modules/pako/lib/utils/common.js +105 -0
- data/node_modules/pako/lib/utils/strings.js +187 -0
- data/node_modules/pako/lib/zlib/README +59 -0
- data/node_modules/pako/lib/zlib/adler32.js +51 -0
- data/node_modules/pako/lib/zlib/constants.js +68 -0
- data/node_modules/pako/lib/zlib/crc32.js +59 -0
- data/node_modules/pako/lib/zlib/deflate.js +1874 -0
- data/node_modules/pako/lib/zlib/gzheader.js +58 -0
- data/node_modules/pako/lib/zlib/inffast.js +345 -0
- data/node_modules/pako/lib/zlib/inflate.js +1556 -0
- data/node_modules/pako/lib/zlib/inftrees.js +343 -0
- data/node_modules/pako/lib/zlib/messages.js +32 -0
- data/node_modules/pako/lib/zlib/trees.js +1222 -0
- data/node_modules/pako/lib/zlib/zstream.js +47 -0
- data/node_modules/pako/package.json +44 -0
- data/node_modules/path-is-absolute/index.js +20 -0
- data/node_modules/path-is-absolute/license +21 -0
- data/node_modules/path-is-absolute/package.json +43 -0
- data/node_modules/path-is-absolute/readme.md +59 -0
- data/node_modules/process-nextick-args/index.js +45 -0
- data/node_modules/process-nextick-args/license.md +19 -0
- data/node_modules/process-nextick-args/package.json +25 -0
- data/node_modules/process-nextick-args/readme.md +18 -0
- data/node_modules/readable-stream/.travis.yml +34 -0
- data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- data/node_modules/readable-stream/GOVERNANCE.md +136 -0
- data/node_modules/readable-stream/LICENSE +47 -0
- data/node_modules/readable-stream/README.md +58 -0
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- data/node_modules/readable-stream/duplex-browser.js +1 -0
- data/node_modules/readable-stream/duplex.js +1 -0
- data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- data/node_modules/readable-stream/package.json +52 -0
- data/node_modules/readable-stream/passthrough.js +1 -0
- data/node_modules/readable-stream/readable-browser.js +7 -0
- data/node_modules/readable-stream/readable.js +19 -0
- data/node_modules/readable-stream/transform.js +1 -0
- data/node_modules/readable-stream/writable-browser.js +1 -0
- data/node_modules/readable-stream/writable.js +8 -0
- data/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/rimraf/README.md +101 -0
- data/node_modules/rimraf/bin.js +50 -0
- data/node_modules/rimraf/package.json +29 -0
- data/node_modules/rimraf/rimraf.js +372 -0
- data/node_modules/safe-buffer/LICENSE +21 -0
- data/node_modules/safe-buffer/README.md +584 -0
- data/node_modules/safe-buffer/index.d.ts +187 -0
- data/node_modules/safe-buffer/index.js +62 -0
- data/node_modules/safe-buffer/package.json +37 -0
- data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
- data/node_modules/selenium-webdriver/LICENSE +202 -0
- data/node_modules/selenium-webdriver/NOTICE +2 -0
- data/node_modules/selenium-webdriver/README.md +229 -0
- data/node_modules/selenium-webdriver/chrome.js +295 -0
- data/node_modules/selenium-webdriver/chromium.js +829 -0
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
- data/node_modules/selenium-webdriver/edge.js +224 -0
- data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
- data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
- data/node_modules/selenium-webdriver/example/google_search.js +50 -0
- data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
- data/node_modules/selenium-webdriver/example/headless.js +63 -0
- data/node_modules/selenium-webdriver/example/logging.js +64 -0
- data/node_modules/selenium-webdriver/firefox.js +789 -0
- data/node_modules/selenium-webdriver/http/index.js +324 -0
- data/node_modules/selenium-webdriver/http/util.js +172 -0
- data/node_modules/selenium-webdriver/ie.js +503 -0
- data/node_modules/selenium-webdriver/index.js +825 -0
- data/node_modules/selenium-webdriver/io/exec.js +162 -0
- data/node_modules/selenium-webdriver/io/index.js +348 -0
- data/node_modules/selenium-webdriver/io/zip.js +223 -0
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
- data/node_modules/selenium-webdriver/lib/by.js +415 -0
- data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
- data/node_modules/selenium-webdriver/lib/command.js +206 -0
- data/node_modules/selenium-webdriver/lib/error.js +605 -0
- data/node_modules/selenium-webdriver/lib/http.js +704 -0
- data/node_modules/selenium-webdriver/lib/input.js +946 -0
- data/node_modules/selenium-webdriver/lib/logging.js +661 -0
- data/node_modules/selenium-webdriver/lib/promise.js +285 -0
- data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
- data/node_modules/selenium-webdriver/lib/session.js +77 -0
- data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
- data/node_modules/selenium-webdriver/lib/until.js +429 -0
- data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
- data/node_modules/selenium-webdriver/net/index.js +107 -0
- data/node_modules/selenium-webdriver/net/portprober.js +75 -0
- data/node_modules/selenium-webdriver/opera.js +406 -0
- data/node_modules/selenium-webdriver/package.json +54 -0
- data/node_modules/selenium-webdriver/proxy.js +32 -0
- data/node_modules/selenium-webdriver/remote/index.js +624 -0
- data/node_modules/selenium-webdriver/safari.js +168 -0
- data/node_modules/selenium-webdriver/testing/index.js +504 -0
- data/node_modules/set-immediate-shim/index.js +7 -0
- data/node_modules/set-immediate-shim/package.json +34 -0
- data/node_modules/set-immediate-shim/readme.md +31 -0
- data/node_modules/string_decoder/.travis.yml +50 -0
- data/node_modules/string_decoder/LICENSE +48 -0
- data/node_modules/string_decoder/README.md +47 -0
- data/node_modules/string_decoder/lib/string_decoder.js +296 -0
- data/node_modules/string_decoder/package.json +31 -0
- data/node_modules/tmp/CHANGELOG.md +288 -0
- data/node_modules/tmp/LICENSE +21 -0
- data/node_modules/tmp/README.md +365 -0
- data/node_modules/tmp/lib/tmp.js +780 -0
- data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
- data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
- data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
- data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
- data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
- data/node_modules/tmp/package.json +58 -0
- data/node_modules/util-deprecate/History.md +16 -0
- data/node_modules/util-deprecate/LICENSE +24 -0
- data/node_modules/util-deprecate/README.md +53 -0
- data/node_modules/util-deprecate/browser.js +67 -0
- data/node_modules/util-deprecate/node.js +6 -0
- data/node_modules/util-deprecate/package.json +27 -0
- data/node_modules/wrappy/LICENSE +15 -0
- data/node_modules/wrappy/README.md +36 -0
- data/node_modules/wrappy/package.json +29 -0
- data/node_modules/wrappy/wrappy.js +33 -0
- data/node_modules/ws/LICENSE +21 -0
- data/node_modules/ws/README.md +496 -0
- data/node_modules/ws/browser.js +8 -0
- data/node_modules/ws/index.js +10 -0
- data/node_modules/ws/lib/buffer-util.js +129 -0
- data/node_modules/ws/lib/constants.js +10 -0
- data/node_modules/ws/lib/event-target.js +184 -0
- data/node_modules/ws/lib/extension.js +223 -0
- data/node_modules/ws/lib/limiter.js +55 -0
- data/node_modules/ws/lib/permessage-deflate.js +517 -0
- data/node_modules/ws/lib/receiver.js +507 -0
- data/node_modules/ws/lib/sender.js +405 -0
- data/node_modules/ws/lib/stream.js +165 -0
- data/node_modules/ws/lib/validation.js +104 -0
- data/node_modules/ws/lib/websocket-server.js +418 -0
- data/node_modules/ws/lib/websocket.js +942 -0
- data/node_modules/ws/package.json +56 -0
- data/package-lock.json +458 -0
- data/package.json +5 -0
- data/selenium.log +1 -0
- metadata +314 -19
@@ -0,0 +1,77 @@
|
|
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 { Capabilities } = require('./capabilities')
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Contains information about a single WebDriver session.
|
24
|
+
*/
|
25
|
+
class Session {
|
26
|
+
/**
|
27
|
+
* @param {string} id The session ID.
|
28
|
+
* @param {!./capabilities.Capabilities} capabilities
|
29
|
+
* The session capabilities.
|
30
|
+
*/
|
31
|
+
constructor(id, capabilities) {
|
32
|
+
/** @private {string} */
|
33
|
+
this.id_ = id
|
34
|
+
|
35
|
+
/** @private {!Capabilities} */
|
36
|
+
this.caps_ =
|
37
|
+
capabilities instanceof Capabilities
|
38
|
+
? /** @type {!Capabilities} */ (capabilities)
|
39
|
+
: new Capabilities(capabilities)
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @return {string} This session's ID.
|
44
|
+
*/
|
45
|
+
getId() {
|
46
|
+
return this.id_
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @return {!Capabilities} This session's capabilities.
|
51
|
+
*/
|
52
|
+
getCapabilities() {
|
53
|
+
return this.caps_
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Retrieves the value of a specific capability.
|
58
|
+
* @param {string} key The capability to retrieve.
|
59
|
+
* @return {*} The capability value.
|
60
|
+
*/
|
61
|
+
getCapability(key) {
|
62
|
+
return this.caps_.get(key)
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Returns the JSON representation of this object, which is just the string
|
67
|
+
* session ID.
|
68
|
+
* @return {string} The JSON representation of this Session.
|
69
|
+
*/
|
70
|
+
toJSON() {
|
71
|
+
return this.getId()
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
// PUBLIC API
|
76
|
+
|
77
|
+
module.exports = { Session: Session }
|
@@ -0,0 +1,37 @@
|
|
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
|
+
/**
|
21
|
+
* @fileoverview Defines well-known symbols used within the selenium-webdriver
|
22
|
+
* library.
|
23
|
+
*/
|
24
|
+
|
25
|
+
module.exports = {
|
26
|
+
/**
|
27
|
+
* The serialize symbol specifies a method that returns an object's serialized
|
28
|
+
* representation. If an object's serialized form is not immediately
|
29
|
+
* available, the serialize method will return a promise that will be resolved
|
30
|
+
* with the serialized form.
|
31
|
+
*
|
32
|
+
* Note that the described method is analogous to objects that define a
|
33
|
+
* `toJSON()` method, except the serialized result may be a promise, or
|
34
|
+
* another object with a promised property.
|
35
|
+
*/
|
36
|
+
serialize: Symbol('serialize'),
|
37
|
+
}
|
@@ -0,0 +1,429 @@
|
|
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 Defines common conditions for use with
|
20
|
+
* {@link webdriver.WebDriver#wait WebDriver wait}.
|
21
|
+
*
|
22
|
+
* Sample usage:
|
23
|
+
*
|
24
|
+
* driver.get('http://www.google.com/ncr');
|
25
|
+
*
|
26
|
+
* var query = driver.wait(until.elementLocated(By.name('q')));
|
27
|
+
* query.sendKeys('webdriver\n');
|
28
|
+
*
|
29
|
+
* driver.wait(until.titleIs('webdriver - Google Search'));
|
30
|
+
*
|
31
|
+
* To define a custom condition, simply call WebDriver.wait with a function
|
32
|
+
* that will eventually return a truthy-value (neither null, undefined, false,
|
33
|
+
* 0, or the empty string):
|
34
|
+
*
|
35
|
+
* driver.wait(function() {
|
36
|
+
* return driver.getTitle().then(function(title) {
|
37
|
+
* return title === 'webdriver - Google Search';
|
38
|
+
* });
|
39
|
+
* }, 1000);
|
40
|
+
*/
|
41
|
+
|
42
|
+
'use strict'
|
43
|
+
|
44
|
+
const by = require('./by')
|
45
|
+
const error = require('./error')
|
46
|
+
const webdriver = require('./webdriver'),
|
47
|
+
Condition = webdriver.Condition,
|
48
|
+
WebElementCondition = webdriver.WebElementCondition
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Creates a condition that will wait until the input driver is able to switch
|
52
|
+
* to the designated frame. The target frame may be specified as
|
53
|
+
*
|
54
|
+
* 1. a numeric index into
|
55
|
+
* [window.frames](https://developer.mozilla.org/en-US/docs/Web/API/Window.frames)
|
56
|
+
* for the currently selected frame.
|
57
|
+
* 2. a {@link ./webdriver.WebElement}, which must reference a FRAME or IFRAME
|
58
|
+
* element on the current page.
|
59
|
+
* 3. a locator which may be used to first locate a FRAME or IFRAME on the
|
60
|
+
* current page before attempting to switch to it.
|
61
|
+
*
|
62
|
+
* Upon successful resolution of this condition, the driver will be left
|
63
|
+
* focused on the new frame.
|
64
|
+
*
|
65
|
+
* @param {!(number|./webdriver.WebElement|By|
|
66
|
+
* function(!./webdriver.WebDriver): !./webdriver.WebElement)} frame
|
67
|
+
* The frame identifier.
|
68
|
+
* @return {!Condition<boolean>} A new condition.
|
69
|
+
*/
|
70
|
+
exports.ableToSwitchToFrame = function ableToSwitchToFrame(frame) {
|
71
|
+
let condition
|
72
|
+
if (typeof frame === 'number' || frame instanceof webdriver.WebElement) {
|
73
|
+
condition = (driver) => attemptToSwitchFrames(driver, frame)
|
74
|
+
} else {
|
75
|
+
condition = function (driver) {
|
76
|
+
let locator = /** @type {!(By|Function)} */ (frame)
|
77
|
+
return driver.findElements(locator).then(function (els) {
|
78
|
+
if (els.length) {
|
79
|
+
return attemptToSwitchFrames(driver, els[0])
|
80
|
+
}
|
81
|
+
})
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
return new Condition('to be able to switch to frame', condition)
|
86
|
+
|
87
|
+
function attemptToSwitchFrames(driver, frame) {
|
88
|
+
return driver
|
89
|
+
.switchTo()
|
90
|
+
.frame(frame)
|
91
|
+
.then(
|
92
|
+
function () {
|
93
|
+
return true
|
94
|
+
},
|
95
|
+
function (e) {
|
96
|
+
if (!(e instanceof error.NoSuchFrameError)) {
|
97
|
+
throw e
|
98
|
+
}
|
99
|
+
}
|
100
|
+
)
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Creates a condition that waits for an alert to be opened. Upon success, the
|
106
|
+
* returned promise will be fulfilled with the handle for the opened alert.
|
107
|
+
*
|
108
|
+
* @return {!Condition<!./webdriver.Alert>} The new condition.
|
109
|
+
*/
|
110
|
+
exports.alertIsPresent = function alertIsPresent() {
|
111
|
+
return new Condition('for alert to be present', function (driver) {
|
112
|
+
return driver
|
113
|
+
.switchTo()
|
114
|
+
.alert()
|
115
|
+
.catch(function (e) {
|
116
|
+
if (
|
117
|
+
!(
|
118
|
+
e instanceof error.NoSuchAlertError ||
|
119
|
+
// XXX: Workaround for GeckoDriver error `TypeError: can't convert null
|
120
|
+
// to object`. For more details, see
|
121
|
+
// https://github.com/SeleniumHQ/selenium/pull/2137
|
122
|
+
(e instanceof error.WebDriverError &&
|
123
|
+
e.message === `can't convert null to object`)
|
124
|
+
)
|
125
|
+
) {
|
126
|
+
throw e
|
127
|
+
}
|
128
|
+
})
|
129
|
+
})
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Creates a condition that will wait for the current page's title to match the
|
134
|
+
* given value.
|
135
|
+
*
|
136
|
+
* @param {string} title The expected page title.
|
137
|
+
* @return {!Condition<boolean>} The new condition.
|
138
|
+
*/
|
139
|
+
exports.titleIs = function titleIs(title) {
|
140
|
+
return new Condition(
|
141
|
+
'for title to be ' + JSON.stringify(title),
|
142
|
+
function (driver) {
|
143
|
+
return driver.getTitle().then(function (t) {
|
144
|
+
return t === title
|
145
|
+
})
|
146
|
+
}
|
147
|
+
)
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Creates a condition that will wait for the current page's title to contain
|
152
|
+
* the given substring.
|
153
|
+
*
|
154
|
+
* @param {string} substr The substring that should be present in the page
|
155
|
+
* title.
|
156
|
+
* @return {!Condition<boolean>} The new condition.
|
157
|
+
*/
|
158
|
+
exports.titleContains = function titleContains(substr) {
|
159
|
+
return new Condition(
|
160
|
+
'for title to contain ' + JSON.stringify(substr),
|
161
|
+
function (driver) {
|
162
|
+
return driver.getTitle().then(function (title) {
|
163
|
+
return title.indexOf(substr) !== -1
|
164
|
+
})
|
165
|
+
}
|
166
|
+
)
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Creates a condition that will wait for the current page's title to match the
|
171
|
+
* given regular expression.
|
172
|
+
*
|
173
|
+
* @param {!RegExp} regex The regular expression to test against.
|
174
|
+
* @return {!Condition<boolean>} The new condition.
|
175
|
+
*/
|
176
|
+
exports.titleMatches = function titleMatches(regex) {
|
177
|
+
return new Condition('for title to match ' + regex, function (driver) {
|
178
|
+
return driver.getTitle().then(function (title) {
|
179
|
+
return regex.test(title)
|
180
|
+
})
|
181
|
+
})
|
182
|
+
}
|
183
|
+
|
184
|
+
/**
|
185
|
+
* Creates a condition that will wait for the current page's url to match the
|
186
|
+
* given value.
|
187
|
+
*
|
188
|
+
* @param {string} url The expected page url.
|
189
|
+
* @return {!Condition<boolean>} The new condition.
|
190
|
+
*/
|
191
|
+
exports.urlIs = function urlIs(url) {
|
192
|
+
return new Condition(
|
193
|
+
'for URL to be ' + JSON.stringify(url),
|
194
|
+
function (driver) {
|
195
|
+
return driver.getCurrentUrl().then(function (u) {
|
196
|
+
return u === url
|
197
|
+
})
|
198
|
+
}
|
199
|
+
)
|
200
|
+
}
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Creates a condition that will wait for the current page's url to contain
|
204
|
+
* the given substring.
|
205
|
+
*
|
206
|
+
* @param {string} substrUrl The substring that should be present in the current
|
207
|
+
* URL.
|
208
|
+
* @return {!Condition<boolean>} The new condition.
|
209
|
+
*/
|
210
|
+
exports.urlContains = function urlContains(substrUrl) {
|
211
|
+
return new Condition(
|
212
|
+
'for URL to contain ' + JSON.stringify(substrUrl),
|
213
|
+
function (driver) {
|
214
|
+
return driver.getCurrentUrl().then(function (url) {
|
215
|
+
return url && url.indexOf(substrUrl) !== -1
|
216
|
+
})
|
217
|
+
}
|
218
|
+
)
|
219
|
+
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Creates a condition that will wait for the current page's url to match the
|
223
|
+
* given regular expression.
|
224
|
+
*
|
225
|
+
* @param {!RegExp} regex The regular expression to test against.
|
226
|
+
* @return {!Condition<boolean>} The new condition.
|
227
|
+
*/
|
228
|
+
exports.urlMatches = function urlMatches(regex) {
|
229
|
+
return new Condition('for URL to match ' + regex, function (driver) {
|
230
|
+
return driver.getCurrentUrl().then(function (url) {
|
231
|
+
return regex.test(url)
|
232
|
+
})
|
233
|
+
})
|
234
|
+
}
|
235
|
+
|
236
|
+
/**
|
237
|
+
* Creates a condition that will loop until an element is
|
238
|
+
* {@link ./webdriver.WebDriver#findElement found} with the given locator.
|
239
|
+
*
|
240
|
+
* @param {!(By|Function)} locator The locator to use.
|
241
|
+
* @return {!WebElementCondition} The new condition.
|
242
|
+
*/
|
243
|
+
exports.elementLocated = function elementLocated(locator) {
|
244
|
+
locator = by.checkedLocator(locator)
|
245
|
+
let locatorStr =
|
246
|
+
typeof locator === 'function' ? 'by function()' : locator + ''
|
247
|
+
return new WebElementCondition(
|
248
|
+
'for element to be located ' + locatorStr,
|
249
|
+
function (driver) {
|
250
|
+
return driver.findElements(locator).then(function (elements) {
|
251
|
+
return elements[0]
|
252
|
+
})
|
253
|
+
}
|
254
|
+
)
|
255
|
+
}
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Creates a condition that will loop until at least one element is
|
259
|
+
* {@link ./webdriver.WebDriver#findElement found} with the given locator.
|
260
|
+
*
|
261
|
+
* @param {!(By|Function)} locator The locator to use.
|
262
|
+
* @return {!Condition<!Array<!./webdriver.WebElement>>} The new
|
263
|
+
* condition.
|
264
|
+
*/
|
265
|
+
exports.elementsLocated = function elementsLocated(locator) {
|
266
|
+
locator = by.checkedLocator(locator)
|
267
|
+
let locatorStr =
|
268
|
+
typeof locator === 'function' ? 'by function()' : locator + ''
|
269
|
+
return new Condition(
|
270
|
+
'for at least one element to be located ' + locatorStr,
|
271
|
+
function (driver) {
|
272
|
+
return driver.findElements(locator).then(function (elements) {
|
273
|
+
return elements.length > 0 ? elements : null
|
274
|
+
})
|
275
|
+
}
|
276
|
+
)
|
277
|
+
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Creates a condition that will wait for the given element to become stale. An
|
281
|
+
* element is considered stale once it is removed from the DOM, or a new page
|
282
|
+
* has loaded.
|
283
|
+
*
|
284
|
+
* @param {!./webdriver.WebElement} element The element that should become stale.
|
285
|
+
* @return {!Condition<boolean>} The new condition.
|
286
|
+
*/
|
287
|
+
exports.stalenessOf = function stalenessOf(element) {
|
288
|
+
return new Condition('element to become stale', function () {
|
289
|
+
return element.getTagName().then(
|
290
|
+
function () {
|
291
|
+
return false
|
292
|
+
},
|
293
|
+
function (e) {
|
294
|
+
if (e instanceof error.StaleElementReferenceError) {
|
295
|
+
return true
|
296
|
+
}
|
297
|
+
throw e
|
298
|
+
}
|
299
|
+
)
|
300
|
+
})
|
301
|
+
}
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Creates a condition that will wait for the given element to become visible.
|
305
|
+
*
|
306
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
307
|
+
* @return {!WebElementCondition} The new condition.
|
308
|
+
* @see ./webdriver.WebDriver#isDisplayed
|
309
|
+
*/
|
310
|
+
exports.elementIsVisible = function elementIsVisible(element) {
|
311
|
+
return new WebElementCondition('until element is visible', function () {
|
312
|
+
return element.isDisplayed().then((v) => (v ? element : null))
|
313
|
+
})
|
314
|
+
}
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Creates a condition that will wait for the given element to be in the DOM,
|
318
|
+
* yet not visible to the user.
|
319
|
+
*
|
320
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
321
|
+
* @return {!WebElementCondition} The new condition.
|
322
|
+
* @see ./webdriver.WebDriver#isDisplayed
|
323
|
+
*/
|
324
|
+
exports.elementIsNotVisible = function elementIsNotVisible(element) {
|
325
|
+
return new WebElementCondition('until element is not visible', function () {
|
326
|
+
return element.isDisplayed().then((v) => (v ? null : element))
|
327
|
+
})
|
328
|
+
}
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Creates a condition that will wait for the given element to be enabled.
|
332
|
+
*
|
333
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
334
|
+
* @return {!WebElementCondition} The new condition.
|
335
|
+
* @see webdriver.WebDriver#isEnabled
|
336
|
+
*/
|
337
|
+
exports.elementIsEnabled = function elementIsEnabled(element) {
|
338
|
+
return new WebElementCondition('until element is enabled', function () {
|
339
|
+
return element.isEnabled().then((v) => (v ? element : null))
|
340
|
+
})
|
341
|
+
}
|
342
|
+
|
343
|
+
/**
|
344
|
+
* Creates a condition that will wait for the given element to be disabled.
|
345
|
+
*
|
346
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
347
|
+
* @return {!WebElementCondition} The new condition.
|
348
|
+
* @see webdriver.WebDriver#isEnabled
|
349
|
+
*/
|
350
|
+
exports.elementIsDisabled = function elementIsDisabled(element) {
|
351
|
+
return new WebElementCondition('until element is disabled', function () {
|
352
|
+
return element.isEnabled().then((v) => (v ? null : element))
|
353
|
+
})
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* Creates a condition that will wait for the given element to be selected.
|
358
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
359
|
+
* @return {!WebElementCondition} The new condition.
|
360
|
+
* @see webdriver.WebDriver#isSelected
|
361
|
+
*/
|
362
|
+
exports.elementIsSelected = function elementIsSelected(element) {
|
363
|
+
return new WebElementCondition('until element is selected', function () {
|
364
|
+
return element.isSelected().then((v) => (v ? element : null))
|
365
|
+
})
|
366
|
+
}
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Creates a condition that will wait for the given element to be deselected.
|
370
|
+
*
|
371
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
372
|
+
* @return {!WebElementCondition} The new condition.
|
373
|
+
* @see webdriver.WebDriver#isSelected
|
374
|
+
*/
|
375
|
+
exports.elementIsNotSelected = function elementIsNotSelected(element) {
|
376
|
+
return new WebElementCondition('until element is not selected', function () {
|
377
|
+
return element.isSelected().then((v) => (v ? null : element))
|
378
|
+
})
|
379
|
+
}
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Creates a condition that will wait for the given element's
|
383
|
+
* {@link webdriver.WebDriver#getText visible text} to match the given
|
384
|
+
* {@code text} exactly.
|
385
|
+
*
|
386
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
387
|
+
* @param {string} text The expected text.
|
388
|
+
* @return {!WebElementCondition} The new condition.
|
389
|
+
* @see webdriver.WebDriver#getText
|
390
|
+
*/
|
391
|
+
exports.elementTextIs = function elementTextIs(element, text) {
|
392
|
+
return new WebElementCondition('until element text is', function () {
|
393
|
+
return element.getText().then((t) => (t === text ? element : null))
|
394
|
+
})
|
395
|
+
}
|
396
|
+
|
397
|
+
/**
|
398
|
+
* Creates a condition that will wait for the given element's
|
399
|
+
* {@link webdriver.WebDriver#getText visible text} to contain the given
|
400
|
+
* substring.
|
401
|
+
*
|
402
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
403
|
+
* @param {string} substr The substring to search for.
|
404
|
+
* @return {!WebElementCondition} The new condition.
|
405
|
+
* @see webdriver.WebDriver#getText
|
406
|
+
*/
|
407
|
+
exports.elementTextContains = function elementTextContains(element, substr) {
|
408
|
+
return new WebElementCondition('until element text contains', function () {
|
409
|
+
return element
|
410
|
+
.getText()
|
411
|
+
.then((t) => (t.indexOf(substr) != -1 ? element : null))
|
412
|
+
})
|
413
|
+
}
|
414
|
+
|
415
|
+
/**
|
416
|
+
* Creates a condition that will wait for the given element's
|
417
|
+
* {@link webdriver.WebDriver#getText visible text} to match a regular
|
418
|
+
* expression.
|
419
|
+
*
|
420
|
+
* @param {!./webdriver.WebElement} element The element to test.
|
421
|
+
* @param {!RegExp} regex The regular expression to test against.
|
422
|
+
* @return {!WebElementCondition} The new condition.
|
423
|
+
* @see webdriver.WebDriver#getText
|
424
|
+
*/
|
425
|
+
exports.elementTextMatches = function elementTextMatches(element, regex) {
|
426
|
+
return new WebElementCondition('until element text matches', function () {
|
427
|
+
return element.getText().then((t) => (regex.test(t) ? element : null))
|
428
|
+
})
|
429
|
+
}
|