async createBrowser()

in lib/runner.ts [204:295]


  async createBrowser(plugins: any, parentBrowser?: ProtractorBrowser): Promise<any> {
    let config = this.config_;
    let driver = await this.driverprovider_.getNewDriver();

    let blockingProxyUrl: string;
    if (config.useBlockingProxy) {
      blockingProxyUrl = this.driverprovider_.getBPUrl();
    }

    let initProperties = {
      baseUrl: config.baseUrl,
      rootElement: config.rootElement as string | Promise<string>,
      untrackOutstandingTimeouts: config.untrackOutstandingTimeouts,
      params: config.params,
      getPageTimeout: config.getPageTimeout,
      allScriptsTimeout: config.allScriptsTimeout,
      debuggerServerPort: config.debuggerServerPort,
      ng12Hybrid: config.ng12Hybrid,
      waitForAngularEnabled: true as boolean | Promise<boolean>
    };

    if (parentBrowser) {
      initProperties.baseUrl = parentBrowser.baseUrl;
      initProperties.rootElement = parentBrowser.angularAppRoot();
      initProperties.untrackOutstandingTimeouts = !parentBrowser.trackOutstandingTimeouts_;
      initProperties.params = parentBrowser.params;
      initProperties.getPageTimeout = parentBrowser.getPageTimeout;
      initProperties.allScriptsTimeout = parentBrowser.allScriptsTimeout;
      initProperties.debuggerServerPort = parentBrowser.debuggerServerPort;
      initProperties.ng12Hybrid = parentBrowser.ng12Hybrid;
      initProperties.waitForAngularEnabled = parentBrowser.waitForAngularEnabled();
    }

    let browser_ = new ProtractorBrowser(
        driver, initProperties.baseUrl, initProperties.rootElement,
        initProperties.untrackOutstandingTimeouts, blockingProxyUrl);

    browser_.params = initProperties.params;
    browser_.plugins_ = plugins || new Plugins({});
    if (initProperties.getPageTimeout) {
      browser_.getPageTimeout = initProperties.getPageTimeout;
    }
    if (initProperties.allScriptsTimeout) {
      browser_.allScriptsTimeout = initProperties.allScriptsTimeout;
    }
    if (initProperties.debuggerServerPort) {
      browser_.debuggerServerPort = initProperties.debuggerServerPort;
    }
    if (initProperties.ng12Hybrid) {
      browser_.ng12Hybrid = initProperties.ng12Hybrid;
    }

    await browser_.waitForAngularEnabled(initProperties.waitForAngularEnabled);
    // TODO(selenium4): Options does not have a setScriptTimeout method.
    await(driver.manage() as any).setTimeouts({script: initProperties.allScriptsTimeout || 0});


    browser_.getProcessedConfig = () => {
      return Promise.resolve(config);
    };

    browser_.forkNewDriverInstance = async(
        useSameUrl: boolean, copyMockModules: boolean, copyConfigUpdates = true): Promise<any> => {
      let newBrowser = await this.createBrowser(plugins);
      if (copyMockModules) {
        newBrowser.mockModules_ = browser_.mockModules_;
      }
      if (useSameUrl) {
        const currentUrl = await browser_.driver.getCurrentUrl();
        await newBrowser.get(currentUrl);
      }
      return newBrowser;
    };

    let replaceBrowser = async () => {
      let newBrowser = await browser_.forkNewDriverInstance(false, true);
      if (browser_ === protractor.browser) {
        this.setupGlobals_(newBrowser);
      }
      return newBrowser;
    };

    browser_.restart = async () => {
      // Note: because tests are not paused at this point, any async
      // calls here are not guaranteed to complete before the tests resume.
      const restartedBrowser = await replaceBrowser();
      await this.driverprovider_.quitDriver(browser_.driver);
      return restartedBrowser;
    };

    return browser_;
  }