* Each WebDriver instance provides automated control over a browser session. * * @implements {IWebDriver}
| 657 | * @implements {IWebDriver} |
| 658 | */ |
| 659 | class WebDriver { |
| 660 | #script = undefined |
| 661 | #network = undefined |
| 662 | /** |
| 663 | * @param {!(./session.Session|IThenable<!./session.Session>)} session Either |
| 664 | * a known session or a promise that will be resolved to a session. |
| 665 | * @param {!command.Executor} executor The executor to use when sending |
| 666 | * commands to the browser. |
| 667 | * @param {(function(this: void): ?)=} onQuit A function to call, if any, |
| 668 | * when the session is terminated. |
| 669 | */ |
| 670 | constructor(session, executor, onQuit = undefined) { |
| 671 | /** @private {!Promise<!Session>} */ |
| 672 | this.session_ = Promise.resolve(session) |
| 673 | |
| 674 | // If session is a rejected promise, add a no-op rejection handler. |
| 675 | // This effectively hides setup errors until users attempt to interact |
| 676 | // with the session. |
| 677 | this.session_.catch(function () {}) |
| 678 | |
| 679 | /** @private {!command.Executor} */ |
| 680 | this.executor_ = executor |
| 681 | |
| 682 | /** @private {input.FileDetector} */ |
| 683 | this.fileDetector_ = null |
| 684 | |
| 685 | /** @private @const {(function(this: void): ?|undefined)} */ |
| 686 | this.onQuit_ = onQuit |
| 687 | |
| 688 | /** @private {./virtual_authenticator}*/ |
| 689 | this.authenticatorId_ = null |
| 690 | |
| 691 | this.pinnedScripts_ = {} |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Creates a new WebDriver session. |
| 696 | * |
| 697 | * This function will always return a WebDriver instance. If there is an error |
| 698 | * creating the session, such as the aforementioned SessionNotCreatedError, |
| 699 | * the driver will have a rejected {@linkplain #getSession session} promise. |
| 700 | * This rejection will propagate through any subsequent commands scheduled |
| 701 | * on the returned WebDriver instance. |
| 702 | * |
| 703 | * let required = Capabilities.firefox(); |
| 704 | * let driver = WebDriver.createSession(executor, {required}); |
| 705 | * |
| 706 | * // If the createSession operation failed, then this command will also |
| 707 | * // also fail, propagating the creation failure. |
| 708 | * driver.get('http://www.google.com').catch(e => console.log(e)); |
| 709 | * |
| 710 | * @param {!command.Executor} executor The executor to create the new session |
| 711 | * with. |
| 712 | * @param {!Capabilities} capabilities The desired capabilities for the new |
| 713 | * session. |
| 714 | * @param {(function(this: void): ?)=} onQuit A callback to invoke when |
| 715 | * the newly created session is terminated. This should be used to clean |
| 716 | * up any resources associated with the session. |
nothing calls this directly
no outgoing calls
no test coverage detected