MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / WebDriver

Class WebDriver

javascript/selenium-webdriver/lib/webdriver.js:661–1875  ·  view source on GitHub ↗

* Each WebDriver instance provides automated control over a browser session. * * @implements {IWebDriver}

Source from the content-addressed store, hash-verified

659 * @implements {IWebDriver}
660 */
661class WebDriver {
662 #script = undefined
663 #accessibility
664 #network = undefined
665 /**
666 * @param {!(./session.Session|IThenable<!./session.Session>)} session Either
667 * a known session or a promise that will be resolved to a session.
668 * @param {!command.Executor} executor The executor to use when sending
669 * commands to the browser.
670 * @param {(function(this: void): ?)=} onQuit A function to call, if any,
671 * when the session is terminated.
672 */
673 constructor(session, executor, onQuit = undefined) {
674 /** @private {!Promise<!Session>} */
675 this.session_ = Promise.resolve(session)
676
677 // If session is a rejected promise, add a no-op rejection handler.
678 // This effectively hides setup errors until users attempt to interact
679 // with the session.
680 this.session_.catch(function () {})
681
682 /** @private {!command.Executor} */
683 this.executor_ = executor
684
685 /** @private {input.FileDetector} */
686 this.fileDetector_ = null
687
688 /** @private @const {(function(this: void): ?|undefined)} */
689 this.onQuit_ = onQuit
690
691 /** @private {./virtual_authenticator}*/
692 this.authenticatorId_ = null
693
694 this.pinnedScripts_ = {}
695 }
696
697 /**
698 * The shared logger deprecation notices (e.g. {@link WebDriver#getBidi})
699 * are emitted through — a class-level accessor since a deprecation can be
700 * reported from a static/prototype context with no driver instance at hand.
701 * @return {!./logging.Logger} the shared `selenium.webdriver.webdriver` logger.
702 */
703 static get logger() {
704 return logging.getLogger('selenium.webdriver.webdriver')
705 }
706
707 /**
708 * Creates a new WebDriver session.
709 *
710 * This function will always return a WebDriver instance. If there is an error
711 * creating the session, such as the aforementioned SessionNotCreatedError,
712 * the driver will have a rejected {@linkplain #getSession session} promise.
713 * This rejection will propagate through any subsequent commands scheduled
714 * on the returned WebDriver instance.
715 *
716 * let required = Capabilities.firefox();
717 * let driver = WebDriver.createSession(executor, {required});
718 *

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected