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

Function init

javascript/selenium-webdriver/testing/index.js:206–252  ·  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

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

Callers 1

suiteFunction · 0.70

Calls 7

infoFunction · 0.85
ErrorFunction · 0.85
getBrowsersToTestFromEnvFunction · 0.85
getAvailableBrowsersFunction · 0.85
joinMethod · 0.80
killMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected