MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / createDriver

Function createDriver

javascript/selenium-webdriver/index.js:126–155  ·  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

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