UrgentcareCLI 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +60 -25
  4. data/Notes +1 -1
  5. data/README.md +5 -5
  6. data/Rakefile +2 -0
  7. data/UrgentCare.gemspec +3 -3
  8. data/background.jpg +0 -0
  9. data/lib/UrgentCare.rb +3 -0
  10. data/lib/UrgentCare/CLI.rb +6 -2
  11. data/lib/UrgentCare/version.rb +1 -1
  12. data/lib/Urgentcare/Scraper.rb +65 -23
  13. data/node_modules/.bin/rimraf +1 -0
  14. data/node_modules/.package-lock.json +250 -0
  15. data/node_modules/balanced-match/.github/FUNDING.yml +2 -0
  16. data/node_modules/balanced-match/LICENSE.md +21 -0
  17. data/node_modules/balanced-match/README.md +97 -0
  18. data/node_modules/balanced-match/index.js +62 -0
  19. data/node_modules/balanced-match/package.json +48 -0
  20. data/node_modules/brace-expansion/LICENSE +21 -0
  21. data/node_modules/brace-expansion/README.md +129 -0
  22. data/node_modules/brace-expansion/index.js +201 -0
  23. data/node_modules/brace-expansion/package.json +47 -0
  24. data/node_modules/concat-map/.travis.yml +4 -0
  25. data/node_modules/concat-map/LICENSE +18 -0
  26. data/node_modules/concat-map/README.markdown +62 -0
  27. data/node_modules/concat-map/example/map.js +6 -0
  28. data/node_modules/concat-map/index.js +13 -0
  29. data/node_modules/concat-map/package.json +43 -0
  30. data/node_modules/concat-map/test/map.js +39 -0
  31. data/node_modules/core-util-is/LICENSE +19 -0
  32. data/node_modules/core-util-is/README.md +3 -0
  33. data/node_modules/core-util-is/float.patch +604 -0
  34. data/node_modules/core-util-is/lib/util.js +107 -0
  35. data/node_modules/core-util-is/package.json +32 -0
  36. data/node_modules/core-util-is/test.js +68 -0
  37. data/node_modules/fs.realpath/LICENSE +43 -0
  38. data/node_modules/fs.realpath/README.md +33 -0
  39. data/node_modules/fs.realpath/index.js +66 -0
  40. data/node_modules/fs.realpath/old.js +303 -0
  41. data/node_modules/fs.realpath/package.json +26 -0
  42. data/node_modules/glob/LICENSE +21 -0
  43. data/node_modules/glob/README.md +375 -0
  44. data/node_modules/glob/changelog.md +67 -0
  45. data/node_modules/glob/common.js +234 -0
  46. data/node_modules/glob/glob.js +788 -0
  47. data/node_modules/glob/package.json +51 -0
  48. data/node_modules/glob/sync.js +484 -0
  49. data/node_modules/immediate/LICENSE.txt +20 -0
  50. data/node_modules/immediate/README.md +93 -0
  51. data/node_modules/immediate/dist/immediate.js +75 -0
  52. data/node_modules/immediate/dist/immediate.min.js +1 -0
  53. data/node_modules/immediate/lib/browser.js +69 -0
  54. data/node_modules/immediate/lib/index.js +73 -0
  55. data/node_modules/immediate/package.json +42 -0
  56. data/node_modules/inflight/LICENSE +15 -0
  57. data/node_modules/inflight/README.md +37 -0
  58. data/node_modules/inflight/inflight.js +54 -0
  59. data/node_modules/inflight/package.json +29 -0
  60. data/node_modules/inherits/LICENSE +16 -0
  61. data/node_modules/inherits/README.md +42 -0
  62. data/node_modules/inherits/inherits.js +9 -0
  63. data/node_modules/inherits/inherits_browser.js +27 -0
  64. data/node_modules/inherits/package.json +29 -0
  65. data/node_modules/isarray/.npmignore +1 -0
  66. data/node_modules/isarray/.travis.yml +4 -0
  67. data/node_modules/isarray/Makefile +6 -0
  68. data/node_modules/isarray/README.md +60 -0
  69. data/node_modules/isarray/component.json +19 -0
  70. data/node_modules/isarray/index.js +5 -0
  71. data/node_modules/isarray/package.json +45 -0
  72. data/node_modules/isarray/test.js +20 -0
  73. data/node_modules/jszip/.codeclimate.yml +16 -0
  74. data/node_modules/jszip/.editorconfig +8 -0
  75. data/node_modules/jszip/.jshintignore +1 -0
  76. data/node_modules/jszip/.jshintrc +21 -0
  77. data/node_modules/jszip/.travis.yml +17 -0
  78. data/node_modules/jszip/CHANGES.md +163 -0
  79. data/node_modules/jszip/LICENSE.markdown +651 -0
  80. data/node_modules/jszip/README.markdown +35 -0
  81. data/node_modules/jszip/dist/jszip.js +30 -0
  82. data/node_modules/jszip/dist/jszip.min.js +13 -0
  83. data/node_modules/jszip/index.d.ts +270 -0
  84. data/node_modules/jszip/lib/base64.js +106 -0
  85. data/node_modules/jszip/lib/compressedObject.js +74 -0
  86. data/node_modules/jszip/lib/compressions.js +14 -0
  87. data/node_modules/jszip/lib/crc32.js +77 -0
  88. data/node_modules/jszip/lib/defaults.js +11 -0
  89. data/node_modules/jszip/lib/external.js +19 -0
  90. data/node_modules/jszip/lib/flate.js +85 -0
  91. data/node_modules/jszip/lib/generate/ZipFileWorker.js +540 -0
  92. data/node_modules/jszip/lib/generate/index.js +57 -0
  93. data/node_modules/jszip/lib/index.js +52 -0
  94. data/node_modules/jszip/lib/license_header.js +11 -0
  95. data/node_modules/jszip/lib/load.js +81 -0
  96. data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
  97. data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
  98. data/node_modules/jszip/lib/nodejsUtils.js +57 -0
  99. data/node_modules/jszip/lib/object.js +389 -0
  100. data/node_modules/jszip/lib/readable-stream-browser.js +9 -0
  101. data/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
  102. data/node_modules/jszip/lib/reader/DataReader.js +116 -0
  103. data/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
  104. data/node_modules/jszip/lib/reader/StringReader.js +38 -0
  105. data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
  106. data/node_modules/jszip/lib/reader/readerFor.js +28 -0
  107. data/node_modules/jszip/lib/signature.js +7 -0
  108. data/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
  109. data/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
  110. data/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
  111. data/node_modules/jszip/lib/stream/DataWorker.js +116 -0
  112. data/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
  113. data/node_modules/jszip/lib/stream/StreamHelper.js +212 -0
  114. data/node_modules/jszip/lib/support.js +38 -0
  115. data/node_modules/jszip/lib/utf8.js +275 -0
  116. data/node_modules/jszip/lib/utils.js +476 -0
  117. data/node_modules/jszip/lib/zipEntries.js +262 -0
  118. data/node_modules/jszip/lib/zipEntry.js +294 -0
  119. data/node_modules/jszip/lib/zipObject.js +133 -0
  120. data/node_modules/jszip/package.json +63 -0
  121. data/node_modules/jszip/vendor/FileSaver.js +247 -0
  122. data/node_modules/lie/README.md +62 -0
  123. data/node_modules/lie/dist/lie.js +350 -0
  124. data/node_modules/lie/dist/lie.min.js +1 -0
  125. data/node_modules/lie/dist/lie.polyfill.js +358 -0
  126. data/node_modules/lie/dist/lie.polyfill.min.js +1 -0
  127. data/node_modules/lie/lib/browser.js +273 -0
  128. data/node_modules/lie/lib/index.js +298 -0
  129. data/node_modules/lie/license.md +7 -0
  130. data/node_modules/lie/lie.d.ts +244 -0
  131. data/node_modules/lie/package.json +69 -0
  132. data/node_modules/lie/polyfill.js +4 -0
  133. data/node_modules/minimatch/LICENSE +15 -0
  134. data/node_modules/minimatch/README.md +209 -0
  135. data/node_modules/minimatch/minimatch.js +923 -0
  136. data/node_modules/minimatch/package.json +30 -0
  137. data/node_modules/once/LICENSE +15 -0
  138. data/node_modules/once/README.md +79 -0
  139. data/node_modules/once/once.js +42 -0
  140. data/node_modules/once/package.json +33 -0
  141. data/node_modules/pako/CHANGELOG.md +164 -0
  142. data/node_modules/pako/LICENSE +21 -0
  143. data/node_modules/pako/README.md +191 -0
  144. data/node_modules/pako/dist/pako.js +6818 -0
  145. data/node_modules/pako/dist/pako.min.js +1 -0
  146. data/node_modules/pako/dist/pako_deflate.js +3997 -0
  147. data/node_modules/pako/dist/pako_deflate.min.js +1 -0
  148. data/node_modules/pako/dist/pako_inflate.js +3300 -0
  149. data/node_modules/pako/dist/pako_inflate.min.js +1 -0
  150. data/node_modules/pako/index.js +14 -0
  151. data/node_modules/pako/lib/deflate.js +400 -0
  152. data/node_modules/pako/lib/inflate.js +423 -0
  153. data/node_modules/pako/lib/utils/common.js +105 -0
  154. data/node_modules/pako/lib/utils/strings.js +187 -0
  155. data/node_modules/pako/lib/zlib/README +59 -0
  156. data/node_modules/pako/lib/zlib/adler32.js +51 -0
  157. data/node_modules/pako/lib/zlib/constants.js +68 -0
  158. data/node_modules/pako/lib/zlib/crc32.js +59 -0
  159. data/node_modules/pako/lib/zlib/deflate.js +1874 -0
  160. data/node_modules/pako/lib/zlib/gzheader.js +58 -0
  161. data/node_modules/pako/lib/zlib/inffast.js +345 -0
  162. data/node_modules/pako/lib/zlib/inflate.js +1556 -0
  163. data/node_modules/pako/lib/zlib/inftrees.js +343 -0
  164. data/node_modules/pako/lib/zlib/messages.js +32 -0
  165. data/node_modules/pako/lib/zlib/trees.js +1222 -0
  166. data/node_modules/pako/lib/zlib/zstream.js +47 -0
  167. data/node_modules/pako/package.json +44 -0
  168. data/node_modules/path-is-absolute/index.js +20 -0
  169. data/node_modules/path-is-absolute/license +21 -0
  170. data/node_modules/path-is-absolute/package.json +43 -0
  171. data/node_modules/path-is-absolute/readme.md +59 -0
  172. data/node_modules/process-nextick-args/index.js +45 -0
  173. data/node_modules/process-nextick-args/license.md +19 -0
  174. data/node_modules/process-nextick-args/package.json +25 -0
  175. data/node_modules/process-nextick-args/readme.md +18 -0
  176. data/node_modules/readable-stream/.travis.yml +34 -0
  177. data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  178. data/node_modules/readable-stream/GOVERNANCE.md +136 -0
  179. data/node_modules/readable-stream/LICENSE +47 -0
  180. data/node_modules/readable-stream/README.md +58 -0
  181. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  182. data/node_modules/readable-stream/duplex-browser.js +1 -0
  183. data/node_modules/readable-stream/duplex.js +1 -0
  184. data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  185. data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  186. data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  187. data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  188. data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
  189. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
  190. data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
  191. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  192. data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  193. data/node_modules/readable-stream/package.json +52 -0
  194. data/node_modules/readable-stream/passthrough.js +1 -0
  195. data/node_modules/readable-stream/readable-browser.js +7 -0
  196. data/node_modules/readable-stream/readable.js +19 -0
  197. data/node_modules/readable-stream/transform.js +1 -0
  198. data/node_modules/readable-stream/writable-browser.js +1 -0
  199. data/node_modules/readable-stream/writable.js +8 -0
  200. data/node_modules/rimraf/LICENSE +15 -0
  201. data/node_modules/rimraf/README.md +101 -0
  202. data/node_modules/rimraf/bin.js +50 -0
  203. data/node_modules/rimraf/package.json +29 -0
  204. data/node_modules/rimraf/rimraf.js +372 -0
  205. data/node_modules/safe-buffer/LICENSE +21 -0
  206. data/node_modules/safe-buffer/README.md +584 -0
  207. data/node_modules/safe-buffer/index.d.ts +187 -0
  208. data/node_modules/safe-buffer/index.js +62 -0
  209. data/node_modules/safe-buffer/package.json +37 -0
  210. data/node_modules/selenium-webdriver/CHANGES.md +1114 -0
  211. data/node_modules/selenium-webdriver/LICENSE +202 -0
  212. data/node_modules/selenium-webdriver/NOTICE +2 -0
  213. data/node_modules/selenium-webdriver/README.md +229 -0
  214. data/node_modules/selenium-webdriver/chrome.js +295 -0
  215. data/node_modules/selenium-webdriver/chromium.js +829 -0
  216. data/node_modules/selenium-webdriver/devtools/CDPConnection.js +35 -0
  217. data/node_modules/selenium-webdriver/edge.js +224 -0
  218. data/node_modules/selenium-webdriver/example/chrome_android.js +45 -0
  219. data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +46 -0
  220. data/node_modules/selenium-webdriver/example/firefox_channels.js +84 -0
  221. data/node_modules/selenium-webdriver/example/google_search.js +50 -0
  222. data/node_modules/selenium-webdriver/example/google_search_test.js +70 -0
  223. data/node_modules/selenium-webdriver/example/headless.js +63 -0
  224. data/node_modules/selenium-webdriver/example/logging.js +64 -0
  225. data/node_modules/selenium-webdriver/firefox.js +789 -0
  226. data/node_modules/selenium-webdriver/http/index.js +324 -0
  227. data/node_modules/selenium-webdriver/http/util.js +172 -0
  228. data/node_modules/selenium-webdriver/ie.js +503 -0
  229. data/node_modules/selenium-webdriver/index.js +825 -0
  230. data/node_modules/selenium-webdriver/io/exec.js +162 -0
  231. data/node_modules/selenium-webdriver/io/index.js +348 -0
  232. data/node_modules/selenium-webdriver/io/zip.js +223 -0
  233. data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +123 -0
  234. data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +101 -0
  235. data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +101 -0
  236. data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +55 -0
  237. data/node_modules/selenium-webdriver/lib/by.js +415 -0
  238. data/node_modules/selenium-webdriver/lib/capabilities.js +553 -0
  239. data/node_modules/selenium-webdriver/lib/command.js +206 -0
  240. data/node_modules/selenium-webdriver/lib/error.js +605 -0
  241. data/node_modules/selenium-webdriver/lib/http.js +704 -0
  242. data/node_modules/selenium-webdriver/lib/input.js +946 -0
  243. data/node_modules/selenium-webdriver/lib/logging.js +661 -0
  244. data/node_modules/selenium-webdriver/lib/promise.js +285 -0
  245. data/node_modules/selenium-webdriver/lib/proxy.js +212 -0
  246. data/node_modules/selenium-webdriver/lib/session.js +77 -0
  247. data/node_modules/selenium-webdriver/lib/symbols.js +37 -0
  248. data/node_modules/selenium-webdriver/lib/until.js +429 -0
  249. data/node_modules/selenium-webdriver/lib/webdriver.js +2919 -0
  250. data/node_modules/selenium-webdriver/net/index.js +107 -0
  251. data/node_modules/selenium-webdriver/net/portprober.js +75 -0
  252. data/node_modules/selenium-webdriver/opera.js +406 -0
  253. data/node_modules/selenium-webdriver/package.json +54 -0
  254. data/node_modules/selenium-webdriver/proxy.js +32 -0
  255. data/node_modules/selenium-webdriver/remote/index.js +624 -0
  256. data/node_modules/selenium-webdriver/safari.js +168 -0
  257. data/node_modules/selenium-webdriver/testing/index.js +504 -0
  258. data/node_modules/set-immediate-shim/index.js +7 -0
  259. data/node_modules/set-immediate-shim/package.json +34 -0
  260. data/node_modules/set-immediate-shim/readme.md +31 -0
  261. data/node_modules/string_decoder/.travis.yml +50 -0
  262. data/node_modules/string_decoder/LICENSE +48 -0
  263. data/node_modules/string_decoder/README.md +47 -0
  264. data/node_modules/string_decoder/lib/string_decoder.js +296 -0
  265. data/node_modules/string_decoder/package.json +31 -0
  266. data/node_modules/tmp/CHANGELOG.md +288 -0
  267. data/node_modules/tmp/LICENSE +21 -0
  268. data/node_modules/tmp/README.md +365 -0
  269. data/node_modules/tmp/lib/tmp.js +780 -0
  270. data/node_modules/tmp/node_modules/.bin/rimraf +1 -0
  271. data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +65 -0
  272. data/node_modules/tmp/node_modules/rimraf/LICENSE +15 -0
  273. data/node_modules/tmp/node_modules/rimraf/README.md +101 -0
  274. data/node_modules/tmp/node_modules/rimraf/bin.js +68 -0
  275. data/node_modules/tmp/node_modules/rimraf/package.json +32 -0
  276. data/node_modules/tmp/node_modules/rimraf/rimraf.js +360 -0
  277. data/node_modules/tmp/package.json +58 -0
  278. data/node_modules/util-deprecate/History.md +16 -0
  279. data/node_modules/util-deprecate/LICENSE +24 -0
  280. data/node_modules/util-deprecate/README.md +53 -0
  281. data/node_modules/util-deprecate/browser.js +67 -0
  282. data/node_modules/util-deprecate/node.js +6 -0
  283. data/node_modules/util-deprecate/package.json +27 -0
  284. data/node_modules/wrappy/LICENSE +15 -0
  285. data/node_modules/wrappy/README.md +36 -0
  286. data/node_modules/wrappy/package.json +29 -0
  287. data/node_modules/wrappy/wrappy.js +33 -0
  288. data/node_modules/ws/LICENSE +21 -0
  289. data/node_modules/ws/README.md +496 -0
  290. data/node_modules/ws/browser.js +8 -0
  291. data/node_modules/ws/index.js +10 -0
  292. data/node_modules/ws/lib/buffer-util.js +129 -0
  293. data/node_modules/ws/lib/constants.js +10 -0
  294. data/node_modules/ws/lib/event-target.js +184 -0
  295. data/node_modules/ws/lib/extension.js +223 -0
  296. data/node_modules/ws/lib/limiter.js +55 -0
  297. data/node_modules/ws/lib/permessage-deflate.js +517 -0
  298. data/node_modules/ws/lib/receiver.js +507 -0
  299. data/node_modules/ws/lib/sender.js +405 -0
  300. data/node_modules/ws/lib/stream.js +165 -0
  301. data/node_modules/ws/lib/validation.js +104 -0
  302. data/node_modules/ws/lib/websocket-server.js +418 -0
  303. data/node_modules/ws/lib/websocket.js +942 -0
  304. data/node_modules/ws/package.json +56 -0
  305. data/package-lock.json +458 -0
  306. data/package.json +5 -0
  307. data/selenium.log +1 -0
  308. metadata +314 -19
@@ -0,0 +1,825 @@
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