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

Function createDriver

javascript/selenium-webdriver/index.js:127–156  ·  view source on GitHub ↗

* @param {function(new: WebDriver, !IThenable<!Session>, ...?)} ctor * @param {...?} args * @return {!ThenableWebDriver}

(ctor, ...args)

Source from the content-addressed store, hash-verified

125 * @return {!ThenableWebDriver}
126 */
127function createDriver(ctor, ...args) {
128 let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor)
129 if (!thenableWebDriverProxy) {
130 /**
131 * @extends {WebDriver} // Needed since `ctor` is dynamically typed.
132 * @implements {ThenableWebDriver}
133 */
134 thenableWebDriverProxy = class extends ctor {
135 /**
136 * @param {!IThenable<!Session>} session
137 * @param {...?} rest
138 */
139 constructor(session, ...rest) {
140 super(session, ...rest)
141
142 const pd = this.getSession().then((session) => {
143 return new ctor(session, ...rest)
144 })
145
146 /** @override */
147 this.then = pd.then.bind(pd)
148
149 /** @override */
150 this.catch = pd.catch.bind(pd)
151 }
152 }
153 THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy)
154 }
155 return thenableWebDriverProxy.createSession(...args)
156}
157
158/**
159 * Creates new {@link webdriver.WebDriver WebDriver} instances. The environment

Callers 1

buildMethod · 0.70

Calls 3

getMethod · 0.65
setMethod · 0.65
createSessionMethod · 0.45

Tested by

no test coverage detected