index.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. * @fileoverview The main user facing module. Exports WebDriver's primary
  19. * public API and provides convenience assessors to certain sub-modules.
  20. */
  21. 'use strict';
  22. const chrome = require('./chrome');
  23. const edge = require('./edge');
  24. const firefox = require('./firefox');
  25. const _http = require('./http');
  26. const ie = require('./ie');
  27. const actions = require('./lib/actions');
  28. const by = require('./lib/by');
  29. const capabilities = require('./lib/capabilities');
  30. const command = require('./lib/command');
  31. const error = require('./lib/error');
  32. const events = require('./lib/events');
  33. const input = require('./lib/input');
  34. const logging = require('./lib/logging');
  35. const promise = require('./lib/promise');
  36. const session = require('./lib/session');
  37. const until = require('./lib/until');
  38. const webdriver = require('./lib/webdriver');
  39. const opera = require('./opera');
  40. const phantomjs = require('./phantomjs');
  41. const remote = require('./remote');
  42. const safari = require('./safari');
  43. const Browser = capabilities.Browser;
  44. const Capabilities = capabilities.Capabilities;
  45. const Capability = capabilities.Capability;
  46. const Session = session.Session;
  47. const WebDriver = webdriver.WebDriver;
  48. var seleniumServer;
  49. /**
  50. * Starts an instance of the Selenium server if not yet running.
  51. * @param {string} jar Path to the server jar to use.
  52. * @return {!Promise<string>} A promise for the server's
  53. * address once started.
  54. */
  55. function startSeleniumServer(jar) {
  56. if (!seleniumServer) {
  57. seleniumServer = new remote.SeleniumServer(jar);
  58. }
  59. return seleniumServer.start();
  60. }
  61. /**
  62. * {@linkplain webdriver.WebDriver#setFileDetector WebDriver's setFileDetector}
  63. * method uses a non-standard command to transfer files from the local client
  64. * to the remote end hosting the browser. Many of the WebDriver sub-types, like
  65. * the {@link chrome.Driver} and {@link firefox.Driver}, do not support this
  66. * command. Thus, these classes override the `setFileDetector` to no-op.
  67. *
  68. * This function uses a mixin to re-enable `setFileDetector` by calling the
  69. * original method on the WebDriver prototype directly. This is used only when
  70. * the builder creates a Chrome or Firefox instance that communicates with a
  71. * remote end (and thus, support for remote file detectors is unknown).
  72. *
  73. * @param {function(new: webdriver.WebDriver, ...?)} ctor
  74. * @return {function(new: webdriver.WebDriver, ...?)}
  75. */
  76. function ensureFileDetectorsAreEnabled(ctor) {
  77. const mixin = class extends ctor {
  78. /** @param {input.FileDetector} detector */
  79. setFileDetector(detector) {
  80. webdriver.WebDriver.prototype.setFileDetector.call(this, detector);
  81. }
  82. };
  83. return mixin;
  84. }
  85. /**
  86. * A thenable wrapper around a {@linkplain webdriver.IWebDriver IWebDriver}
  87. * instance that allows commands to be issued directly instead of having to
  88. * repeatedly call `then`:
  89. *
  90. * let driver = new Builder().build();
  91. * driver.then(d => d.get(url)); // You can do this...
  92. * driver.get(url); // ...or this
  93. *
  94. * If the driver instance fails to resolve (e.g. the session cannot be created),
  95. * every issued command will fail.
  96. *
  97. * @extends {webdriver.IWebDriver}
  98. * @extends {promise.CancellableThenable<!webdriver.IWebDriver>}
  99. * @interface
  100. */
  101. class ThenableWebDriver {
  102. /** @param {...?} args */
  103. static createSession(...args) {}
  104. }
  105. /**
  106. * @const {!Map<function(new: WebDriver, !IThenable<!Session>, ...?),
  107. * function(new: ThenableWebDriver, !IThenable<!Session>, ...?)>}
  108. */
  109. const THENABLE_DRIVERS = new Map;
  110. /**
  111. * @param {function(new: WebDriver, !IThenable<!Session>, ...?)} ctor
  112. * @param {...?} args
  113. * @return {!ThenableWebDriver}
  114. */
  115. function createDriver(ctor, ...args) {
  116. let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor);
  117. if (!thenableWebDriverProxy) {
  118. /**
  119. * @extends {WebDriver} // Needed since `ctor` is dynamically typed.
  120. * @implements {ThenableWebDriver}
  121. */
  122. thenableWebDriverProxy = class extends ctor {
  123. /**
  124. * @param {!IThenable<!Session>} session
  125. * @param {...?} rest
  126. */
  127. constructor(session, ...rest) {
  128. super(session, ...rest);
  129. const pd = this.getSession().then(session => {
  130. return new ctor(session, ...rest);
  131. });
  132. /**
  133. * @param {(string|Error)=} opt_reason
  134. * @override
  135. */
  136. this.cancel = function(opt_reason) {
  137. if (promise.CancellableThenable.isImplementation(pd)) {
  138. /** @type {!promise.CancellableThenable} */(pd).cancel(opt_reason);
  139. }
  140. };
  141. /** @override */
  142. this.then = pd.then.bind(pd);
  143. /** @override */
  144. this.catch = pd.then.bind(pd);
  145. }
  146. };
  147. promise.CancellableThenable.addImplementation(thenableWebDriverProxy);
  148. THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy);
  149. }
  150. return thenableWebDriverProxy.createSession(...args);
  151. }
  152. /**
  153. * Creates new {@link webdriver.WebDriver WebDriver} instances. The environment
  154. * variables listed below may be used to override a builder's configuration,
  155. * allowing quick runtime changes.
  156. *
  157. * - {@code SELENIUM_BROWSER}: defines the target browser in the form
  158. * {@code browser[:version][:platform]}.
  159. *
  160. * - {@code SELENIUM_REMOTE_URL}: defines the remote URL for all builder
  161. * instances. This environment variable should be set to a fully qualified
  162. * URL for a WebDriver server (e.g. http://localhost:4444/wd/hub). This
  163. * option always takes precedence over {@code SELENIUM_SERVER_JAR}.
  164. *
  165. * - {@code SELENIUM_SERVER_JAR}: defines the path to the
  166. * <a href="http://selenium-release.storage.googleapis.com/index.html">
  167. * standalone Selenium server</a> jar to use. The server will be started the
  168. * first time a WebDriver instance and be killed when the process exits.
  169. *
  170. * Suppose you had mytest.js that created WebDriver with
  171. *
  172. * var driver = new webdriver.Builder()
  173. * .forBrowser('chrome')
  174. * .build();
  175. *
  176. * This test could be made to use Firefox on the local machine by running with
  177. * `SELENIUM_BROWSER=firefox node mytest.js`. Rather than change the code to
  178. * target Google Chrome on a remote machine, you can simply set the
  179. * `SELENIUM_BROWSER` and `SELENIUM_REMOTE_URL` environment variables:
  180. *
  181. * SELENIUM_BROWSER=chrome:36:LINUX \
  182. * SELENIUM_REMOTE_URL=http://www.example.com:4444/wd/hub \
  183. * node mytest.js
  184. *
  185. * You could also use a local copy of the standalone Selenium server:
  186. *
  187. * SELENIUM_BROWSER=chrome:36:LINUX \
  188. * SELENIUM_SERVER_JAR=/path/to/selenium-server-standalone.jar \
  189. * node mytest.js
  190. */
  191. class Builder {
  192. constructor() {
  193. /** @private @const */
  194. this.log_ = logging.getLogger('webdriver.Builder');
  195. /** @private {promise.ControlFlow} */
  196. this.flow_ = null;
  197. /** @private {string} */
  198. this.url_ = '';
  199. /** @private {?string} */
  200. this.proxy_ = null;
  201. /** @private {!Capabilities} */
  202. this.capabilities_ = new Capabilities();
  203. /** @private {chrome.Options} */
  204. this.chromeOptions_ = null;
  205. /** @private {firefox.Options} */
  206. this.firefoxOptions_ = null;
  207. /** @private {opera.Options} */
  208. this.operaOptions_ = null;
  209. /** @private {ie.Options} */
  210. this.ieOptions_ = null;
  211. /** @private {safari.Options} */
  212. this.safariOptions_ = null;
  213. /** @private {edge.Options} */
  214. this.edgeOptions_ = null;
  215. /** @private {boolean} */
  216. this.ignoreEnv_ = false;
  217. /** @private {http.Agent} */
  218. this.agent_ = null;
  219. }
  220. /**
  221. * Configures this builder to ignore any environment variable overrides and to
  222. * only use the configuration specified through this instance's API.
  223. *
  224. * @return {!Builder} A self reference.
  225. */
  226. disableEnvironmentOverrides() {
  227. this.ignoreEnv_ = true;
  228. return this;
  229. }
  230. /**
  231. * Sets the URL of a remote WebDriver server to use. Once a remote URL has
  232. * been specified, the builder direct all new clients to that server. If this
  233. * method is never called, the Builder will attempt to create all clients
  234. * locally.
  235. *
  236. * As an alternative to this method, you may also set the
  237. * `SELENIUM_REMOTE_URL` environment variable.
  238. *
  239. * @param {string} url The URL of a remote server to use.
  240. * @return {!Builder} A self reference.
  241. */
  242. usingServer(url) {
  243. this.url_ = url;
  244. return this;
  245. }
  246. /**
  247. * @return {string} The URL of the WebDriver server this instance is
  248. * configured to use.
  249. */
  250. getServerUrl() {
  251. return this.url_;
  252. }
  253. /**
  254. * Sets the URL of the proxy to use for the WebDriver's HTTP connections.
  255. * If this method is never called, the Builder will create a connection
  256. * without a proxy.
  257. *
  258. * @param {string} proxy The URL of a proxy to use.
  259. * @return {!Builder} A self reference.
  260. */
  261. usingWebDriverProxy(proxy) {
  262. this.proxy_ = proxy;
  263. return this;
  264. }
  265. /**
  266. * @return {?string} The URL of the proxy server to use for the WebDriver's
  267. * HTTP connections, or `null` if not set.
  268. */
  269. getWebDriverProxy() {
  270. return this.proxy_;
  271. }
  272. /**
  273. * Sets the http agent to use for each request.
  274. * If this method is not called, the Builder will use http.globalAgent by default.
  275. *
  276. * @param {http.Agent} agent The agent to use for each request.
  277. * @return {!Builder} A self reference.
  278. */
  279. usingHttpAgent(agent) {
  280. this.agent_ = agent;
  281. return this;
  282. }
  283. /**
  284. * @return {http.Agent} The http agent used for each request
  285. */
  286. getHttpAgent() {
  287. return this.agent_;
  288. }
  289. /**
  290. * Sets the desired capabilities when requesting a new session. This will
  291. * overwrite any previously set capabilities.
  292. * @param {!(Object|Capabilities)} capabilities The desired capabilities for
  293. * a new session.
  294. * @return {!Builder} A self reference.
  295. */
  296. withCapabilities(capabilities) {
  297. this.capabilities_ = new Capabilities(capabilities);
  298. return this;
  299. }
  300. /**
  301. * Returns the base set of capabilities this instance is currently configured
  302. * to use.
  303. * @return {!Capabilities} The current capabilities for this builder.
  304. */
  305. getCapabilities() {
  306. return this.capabilities_;
  307. }
  308. /**
  309. * Configures the target browser for clients created by this instance.
  310. * Any calls to {@link #withCapabilities} after this function will
  311. * overwrite these settings.
  312. *
  313. * You may also define the target browser using the {@code SELENIUM_BROWSER}
  314. * environment variable. If set, this environment variable should be of the
  315. * form `browser[:[version][:platform]]`.
  316. *
  317. * @param {(string|Browser)} name The name of the target browser;
  318. * common defaults are available on the {@link webdriver.Browser} enum.
  319. * @param {string=} opt_version A desired version; may be omitted if any
  320. * version should be used.
  321. * @param {string=} opt_platform The desired platform; may be omitted if any
  322. * version may be used.
  323. * @return {!Builder} A self reference.
  324. */
  325. forBrowser(name, opt_version, opt_platform) {
  326. this.capabilities_.set(Capability.BROWSER_NAME, name);
  327. this.capabilities_.set(Capability.VERSION, opt_version || null);
  328. this.capabilities_.set(Capability.PLATFORM, opt_platform || null);
  329. return this;
  330. }
  331. /**
  332. * Sets the proxy configuration for the target browser.
  333. * Any calls to {@link #withCapabilities} after this function will
  334. * overwrite these settings.
  335. *
  336. * @param {!capabilities.ProxyConfig} config The configuration to use.
  337. * @return {!Builder} A self reference.
  338. */
  339. setProxy(config) {
  340. this.capabilities_.setProxy(config);
  341. return this;
  342. }
  343. /**
  344. * Sets the logging preferences for the created session. Preferences may be
  345. * changed by repeated calls, or by calling {@link #withCapabilities}.
  346. * @param {!(./lib/logging.Preferences|Object<string, string>)} prefs The
  347. * desired logging preferences.
  348. * @return {!Builder} A self reference.
  349. */
  350. setLoggingPrefs(prefs) {
  351. this.capabilities_.setLoggingPrefs(prefs);
  352. return this;
  353. }
  354. /**
  355. * Sets whether native events should be used.
  356. * @param {boolean} enabled Whether to enable native events.
  357. * @return {!Builder} A self reference.
  358. */
  359. setEnableNativeEvents(enabled) {
  360. this.capabilities_.setEnableNativeEvents(enabled);
  361. return this;
  362. }
  363. /**
  364. * Sets how elements should be scrolled into view for interaction.
  365. * @param {number} behavior The desired scroll behavior: either 0 to align
  366. * with the top of the viewport or 1 to align with the bottom.
  367. * @return {!Builder} A self reference.
  368. */
  369. setScrollBehavior(behavior) {
  370. this.capabilities_.setScrollBehavior(behavior);
  371. return this;
  372. }
  373. /**
  374. * Sets the default action to take with an unexpected alert before returning
  375. * an error.
  376. * @param {string} behavior The desired behavior; should be "accept",
  377. * "dismiss", or "ignore". Defaults to "dismiss".
  378. * @return {!Builder} A self reference.
  379. */
  380. setAlertBehavior(behavior) {
  381. this.capabilities_.setAlertBehavior(behavior);
  382. return this;
  383. }
  384. /**
  385. * Sets Chrome specific {@linkplain chrome.Options options} for drivers
  386. * created by this builder. Any logging or proxy settings defined on the given
  387. * options will take precedence over those set through
  388. * {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
  389. *
  390. * @param {!chrome.Options} options The ChromeDriver options to use.
  391. * @return {!Builder} A self reference.
  392. */
  393. setChromeOptions(options) {
  394. this.chromeOptions_ = options;
  395. return this;
  396. }
  397. /**
  398. * Sets Firefox specific {@linkplain firefox.Options options} for drivers
  399. * created by this builder. Any logging or proxy settings defined on the given
  400. * options will take precedence over those set through
  401. * {@link #setLoggingPrefs} and {@link #setProxy}, respectively.
  402. *
  403. * @param {!firefox.Options} options The FirefoxDriver options to use.
  404. * @return {!Builder} A self reference.
  405. */
  406. setFirefoxOptions(options) {
  407. this.firefoxOptions_ = options;
  408. return this;
  409. }
  410. /**
  411. * @return {firefox.Options} the Firefox specific options currently configured
  412. * for this instance.
  413. */
  414. getFirefoxOptions() {
  415. return this.firefoxOptions_;
  416. }
  417. /**
  418. * Sets Opera specific {@linkplain opera.Options options} for drivers created
  419. * by this builder. Any logging or proxy settings defined on the given options
  420. * will take precedence over those set through {@link #setLoggingPrefs} and
  421. * {@link #setProxy}, respectively.
  422. *
  423. * @param {!opera.Options} options The OperaDriver options to use.
  424. * @return {!Builder} A self reference.
  425. */
  426. setOperaOptions(options) {
  427. this.operaOptions_ = options;
  428. return this;
  429. }
  430. /**
  431. * Set Internet Explorer specific {@linkplain ie.Options options} for drivers
  432. * created by this builder. Any proxy settings defined on the given options
  433. * will take precedence over those set through {@link #setProxy}.
  434. *
  435. * @param {!ie.Options} options The IEDriver options to use.
  436. * @return {!Builder} A self reference.
  437. */
  438. setIeOptions(options) {
  439. this.ieOptions_ = options;
  440. return this;
  441. }
  442. /**
  443. * Set {@linkplain edge.Options options} specific to Microsoft's Edge browser
  444. * for drivers created by this builder. Any proxy settings defined on the
  445. * given options will take precedence over those set through
  446. * {@link #setProxy}.
  447. *
  448. * @param {!edge.Options} options The MicrosoftEdgeDriver options to use.
  449. * @return {!Builder} A self reference.
  450. */
  451. setEdgeOptions(options) {
  452. this.edgeOptions_ = options;
  453. return this;
  454. }
  455. /**
  456. * Sets Safari specific {@linkplain safari.Options options} for drivers
  457. * created by this builder. Any logging settings defined on the given options
  458. * will take precedence over those set through {@link #setLoggingPrefs}.
  459. *
  460. * @param {!safari.Options} options The Safari options to use.
  461. * @return {!Builder} A self reference.
  462. */
  463. setSafariOptions(options) {
  464. this.safariOptions_ = options;
  465. return this;
  466. }
  467. /**
  468. * @return {safari.Options} the Safari specific options currently configured
  469. * for this instance.
  470. */
  471. getSafariOptions() {
  472. return this.safariOptions_;
  473. }
  474. /**
  475. * Sets the control flow that created drivers should execute actions in. If
  476. * the flow is never set, or is set to {@code null}, it will use the active
  477. * flow at the time {@link #build()} is called.
  478. * @param {promise.ControlFlow} flow The control flow to use, or
  479. * {@code null} to
  480. * @return {!Builder} A self reference.
  481. */
  482. setControlFlow(flow) {
  483. this.flow_ = flow;
  484. return this;
  485. }
  486. /**
  487. * Creates a new WebDriver client based on this builder's current
  488. * configuration.
  489. *
  490. * This method will return a {@linkplain ThenableWebDriver} instance, allowing
  491. * users to issue commands directly without calling `then()`. The returned
  492. * thenable wraps a promise that will resolve to a concrete
  493. * {@linkplain webdriver.WebDriver WebDriver} instance. The promise will be
  494. * rejected if the remote end fails to create a new session.
  495. *
  496. * @return {!ThenableWebDriver} A new WebDriver instance.
  497. * @throws {Error} If the current configuration is invalid.
  498. */
  499. build() {
  500. // Create a copy for any changes we may need to make based on the current
  501. // environment.
  502. var capabilities = new Capabilities(this.capabilities_);
  503. var browser;
  504. if (!this.ignoreEnv_ && process.env.SELENIUM_BROWSER) {
  505. this.log_.fine(`SELENIUM_BROWSER=${process.env.SELENIUM_BROWSER}`);
  506. browser = process.env.SELENIUM_BROWSER.split(/:/, 3);
  507. capabilities.set(Capability.BROWSER_NAME, browser[0]);
  508. capabilities.set(Capability.VERSION, browser[1] || null);
  509. capabilities.set(Capability.PLATFORM, browser[2] || null);
  510. }
  511. browser = capabilities.get(Capability.BROWSER_NAME);
  512. if (typeof browser !== 'string') {
  513. throw TypeError(
  514. `Target browser must be a string, but is <${typeof browser}>;` +
  515. ' did you forget to call forBrowser()?');
  516. }
  517. if (browser === 'ie') {
  518. browser = Browser.INTERNET_EXPLORER;
  519. }
  520. // Apply browser specific overrides.
  521. if (browser === Browser.CHROME && this.chromeOptions_) {
  522. capabilities.merge(this.chromeOptions_.toCapabilities());
  523. } else if (browser === Browser.FIREFOX && this.firefoxOptions_) {
  524. capabilities.merge(this.firefoxOptions_.toCapabilities());
  525. } else if (browser === Browser.INTERNET_EXPLORER && this.ieOptions_) {
  526. capabilities.merge(this.ieOptions_.toCapabilities());
  527. } else if (browser === Browser.OPERA && this.operaOptions_) {
  528. capabilities.merge(this.operaOptions_.toCapabilities());
  529. } else if (browser === Browser.SAFARI && this.safariOptions_) {
  530. capabilities.merge(this.safariOptions_.toCapabilities());
  531. } else if (browser === Browser.EDGE && this.edgeOptions_) {
  532. capabilities.merge(this.edgeOptions_.toCapabilities());
  533. }
  534. // Check for a remote browser.
  535. let url = this.url_;
  536. if (!this.ignoreEnv_) {
  537. if (process.env.SELENIUM_REMOTE_URL) {
  538. this.log_.fine(
  539. `SELENIUM_REMOTE_URL=${process.env.SELENIUM_REMOTE_URL}`);
  540. url = process.env.SELENIUM_REMOTE_URL;
  541. } else if (process.env.SELENIUM_SERVER_JAR) {
  542. this.log_.fine(
  543. `SELENIUM_SERVER_JAR=${process.env.SELENIUM_SERVER_JAR}`);
  544. url = startSeleniumServer(process.env.SELENIUM_SERVER_JAR);
  545. }
  546. }
  547. if (url) {
  548. this.log_.fine('Creating session on remote server');
  549. let client = Promise.resolve(url)
  550. .then(url => new _http.HttpClient(url, this.agent_, this.proxy_));
  551. let executor = new _http.Executor(client);
  552. if (browser === Browser.CHROME) {
  553. const driver = ensureFileDetectorsAreEnabled(chrome.Driver);
  554. return createDriver(
  555. driver, capabilities, executor, this.flow_);
  556. }
  557. if (browser === Browser.FIREFOX) {
  558. const driver = ensureFileDetectorsAreEnabled(firefox.Driver);
  559. return createDriver(
  560. driver, capabilities, executor, this.flow_);
  561. }
  562. return createDriver(
  563. WebDriver, executor, capabilities, this.flow_);
  564. }
  565. // Check for a native browser.
  566. switch (browser) {
  567. case Browser.CHROME:
  568. return createDriver(chrome.Driver, capabilities, null, this.flow_);
  569. case Browser.FIREFOX:
  570. return createDriver(firefox.Driver, capabilities, null, this.flow_);
  571. case Browser.INTERNET_EXPLORER:
  572. return createDriver(ie.Driver, capabilities, this.flow_);
  573. case Browser.EDGE:
  574. return createDriver(edge.Driver, capabilities, null, this.flow_);
  575. case Browser.OPERA:
  576. return createDriver(opera.Driver, capabilities, null, this.flow_);
  577. case Browser.PHANTOM_JS:
  578. return createDriver(phantomjs.Driver, capabilities, this.flow_);
  579. case Browser.SAFARI:
  580. return createDriver(safari.Driver, capabilities, this.flow_);
  581. default:
  582. throw new Error('Do not know how to build driver: ' + browser
  583. + '; did you forget to call usingServer(url)?');
  584. }
  585. }
  586. }
  587. // PUBLIC API
  588. exports.ActionSequence = actions.ActionSequence;
  589. exports.Browser = capabilities.Browser;
  590. exports.Builder = Builder;
  591. exports.Button = input.Button;
  592. exports.By = by.By;
  593. exports.Capabilities = capabilities.Capabilities;
  594. exports.Capability = capabilities.Capability;
  595. exports.Condition = webdriver.Condition;
  596. exports.EventEmitter = events.EventEmitter;
  597. exports.FileDetector = input.FileDetector;
  598. exports.Key = input.Key;
  599. exports.Session = session.Session;
  600. exports.ThenableWebDriver = ThenableWebDriver;
  601. exports.TouchSequence = actions.TouchSequence;
  602. exports.WebDriver = webdriver.WebDriver;
  603. exports.WebElement = webdriver.WebElement;
  604. exports.WebElementCondition = webdriver.WebElementCondition;
  605. exports.WebElementPromise = webdriver.WebElementPromise;
  606. exports.error = error;
  607. exports.logging = logging;
  608. exports.promise = promise;
  609. exports.until = until;