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

Function init

javascript/selenium-webdriver/testing/index.js:211–258  ·  view source on GitHub ↗

* Initializes this module by determining which browsers a * plain ./index.suite test suite should run against. The default * behavior is to run tests against every browser with a WebDriver executables * (chromedriver, firefoxdriver, etc.) are installed on the system by `PATH`. * * Specif

(force = false)

Source from the content-addressed store, hash-verified

209 * against.
210 */
211function init(force = false) {
212 if (wasInit && !force) {
213 return
214 }
215 wasInit = true
216
217 // If force re-init, kill the current server if there is one.
218 if (seleniumServer) {
219 seleniumServer.kill()
220 seleniumServer = null
221 }
222
223 seleniumJar = process.env['SELENIUM_SERVER_JAR']
224 seleniumUrl = process.env['SELENIUM_REMOTE_URL']
225 if (seleniumJar) {
226 seleniumJar = locate(seleniumJar)
227 info(`Using Selenium server jar: ${seleniumJar}`)
228 }
229
230 if (seleniumUrl) {
231 info(`Using Selenium remote end: ${seleniumUrl}`)
232 }
233
234 if (seleniumJar && seleniumUrl) {
235 throw Error(
236 'Ambiguous test configuration: both SELENIUM_REMOTE_URL' +
237 ' && SELENIUM_SERVER_JAR environment variables are set',
238 )
239 }
240
241 const envBrowsers = getBrowsersToTestFromEnv()
242 if ((seleniumJar || seleniumUrl) && envBrowsers.length === 0) {
243 throw Error(
244 'Ambiguous test configuration: when either the SELENIUM_REMOTE_URL or' +
245 ' SELENIUM_SERVER_JAR environment variable is set, the' +
246 ' SELENIUM_BROWSER variable must also be set.',
247 )
248 }
249
250 targetBrowsers = envBrowsers.length > 0 ? envBrowsers : getAvailableBrowsers()
251 info(`Running tests against [${targetBrowsers.map((b) => b.name).join(', ')}]`)
252
253 after(function () {
254 if (seleniumServer) {
255 return seleniumServer.kill()
256 }
257 })
258}
259
260const TARGET_MAP = /** !WeakMap<!Environment, !TargetBrowser> */ new WeakMap()
261const URL_MAP = /** !WeakMap<!Environment, ?(string|remote.SeleniumServer)> */ new WeakMap()

Callers 1

suiteFunction · 0.85

Calls 7

locateFunction · 0.85
infoFunction · 0.85
getBrowsersToTestFromEnvFunction · 0.85
getAvailableBrowsersFunction · 0.85
ErrorFunction · 0.50
killMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected