Build a new WebDriver based EmbeddedBrowser.

@return the new build WebDriver based embeddedBrowser
515138
@Override
	public EmbeddedBrowser get() {
		LOGGER.debug("Setting up a Browser");
		// Retrieve the config values used
		ImmutableSortedSet<String> filterAttributes =
				configuration.getCrawlRules().getPreCrawlConfig().getFilterAttributeNames();
		long crawlWaitReload = configuration.getCrawlRules().getWaitAfterReloadUrl();
		long crawlWaitEvent = configuration.getCrawlRules().getWaitAfterEvent();

		// Determine the requested browser type
		EmbeddedBrowser browser = null;
		EmbeddedBrowser.BrowserType browserType =
				configuration.getBrowserConfig().getBrowserType();
		try {
			switch (browserType) {
				case CHROME:
					browser = newChromeBrowser(filterAttributes, crawlWaitReload, crawlWaitEvent,
							false);
					break;
				case CHROME_HEADLESS:
					browser = newChromeBrowser(filterAttributes, crawlWaitReload,
							crawlWaitEvent, true);
					break;
				case FIREFOX:
					browser = newFirefoxBrowser(filterAttributes, crawlWaitReload, crawlWaitEvent,
							false);
					break;
				case FIREFOX_HEADLESS:
					browser = newFirefoxBrowser(filterAttributes, crawlWaitReload, crawlWaitEvent,
							true);
					break;
				case REMOTE:
					browser = WebDriverBackedEmbeddedBrowser.withRemoteDriver(
							configuration.getBrowserConfig().getRemoteHubUrl(), filterAttributes,
							crawlWaitEvent, crawlWaitReload);
					break;
				case PHANTOMJS:
					browser =
							newPhantomJSDriver(filterAttributes, crawlWaitReload, crawlWaitEvent);
					break;
				default:
					throw new IllegalStateException("Unrecognized browser type "
							+ configuration.getBrowserConfig().getBrowserType());
			}
		} catch (IllegalStateException e) {
			LOGGER.error("Crawling with {} failed: " + e.getMessage(), browserType.toString());
			throw e;
		}

		/* for Retina display. */
		if (browser instanceof WebDriverBackedEmbeddedBrowser) {
			int pixelDensity =
					this.configuration.getBrowserConfig().getBrowserOptions().getPixelDensity();
			if (pixelDensity != -1)
				((WebDriverBackedEmbeddedBrowser) browser).setPixelDensity(pixelDensity);
		}

		plugins.runOnBrowserCreatedPlugins(browser);
		return browser;
	}
746333
public WebDriver getDriver() {
        // Driver's name is retrieved by system properties
        String driverName = Context.getBrowser();
        driverName = driverName != null ? driverName : DEFAULT_DRIVER;
        WebDriver driver = null;
        if (!drivers.containsKey(driverName)) {
            try {
                driver = generateWebDriver(driverName);
            } catch (final TechnicalException e) {
                logger.error("error DriverFactory.getDriver()", e);
            }
        } else {
            driver = drivers.get(driverName);
        }
        return driver;
    }
844038
public static Builder builder() {
    return new AutoValue_StackdriverTraceConfiguration.Builder()
        .setProjectId(DEFAULT_PROJECT_ID)
        .setFixedAttributes(Collections.<String, AttributeValue>emptyMap());
  }
517227
public String build() {
        StringBuilder scriptBuilder = new StringBuilder();
        StringBuilder scriptBody = new StringBuilder();
        String importStmt = "import ";
        
        try {
            if (scriptCode.contains(importStmt)) {
                BufferedReader reader = new BufferedReader(new StringReader(scriptCode));
                String line;
                while ((line = reader.readLine()) != null) {
                    if (line.trim().startsWith(importStmt)) {
                        scriptBuilder.append(line);
                        scriptBuilder.append("\n");
                    } else {
                        scriptBody.append((scriptBody.length() == 0 ? "" : "\n"));
                        scriptBody.append(line);
                    }
                }
            } else {
                scriptBody.append(scriptCode);
            }
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to construct script from template", e);
        }
        
        scriptBuilder.append(scriptHead);
        scriptBuilder.append(scriptBody.toString());
        scriptBuilder.append(scriptTail);
        
        return scriptBuilder.toString();
    }
650519
protected T build() {
        if (encoder != null) {
            assert decoder != null;
            return buildFromCodec(decoder, encoder);
        }

        Http2Connection connection = this.connection;
        if (connection == null) {
            connection = new DefaultHttp2Connection(isServer(), maxReservedStreams());
        }

        return buildFromConnection(connection);
    }
722004
public WebDriver setupDriver() throws InvalidBrowserException {
        WebDriver driver;
        // check the browser
        switch (browser.getName()) {
            case HTMLUNIT:
                System.getProperties().put("org.apache.commons.logging.simplelog.defaultlog", "fatal");
                java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
                java.util.logging.Logger.getLogger("org.apache.http").setLevel(Level.OFF);
                driver = new HtmlUnitDriver(desiredCapabilities);
                break;
            case FIREFOX:
                WebDriverManager.firefoxdriver().forceCache().setup();
                FirefoxOptions firefoxOptions = new FirefoxOptions(desiredCapabilities);
                firefoxOptions.addArguments(getBrowserOptions());
                if (Property.runHeadless()) {
                    firefoxOptions.setHeadless(true);
                }
                driver = new FirefoxDriver(firefoxOptions);
                break;
            case CHROME:
                WebDriverManager.chromedriver().forceCache().setup();
                ChromeOptions chromeOptions = new ChromeOptions();
                chromeOptions = chromeOptions.merge(desiredCapabilities);
                chromeOptions.addArguments(getBrowserOptions());
                if (Property.runHeadless()) {
                    chromeOptions.setHeadless(true);
                }
                driver = new ChromeDriver(chromeOptions);
                break;
            case INTERNETEXPLORER:
                WebDriverManager.iedriver().forceCache().setup();
                InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions(desiredCapabilities);
                driver = new InternetExplorerDriver(internetExplorerOptions);
                break;
            case EDGE:
                WebDriverManager.edgedriver().forceCache().setup();
                EdgeOptions edgeOptions = new EdgeOptions();
                edgeOptions = edgeOptions.merge(desiredCapabilities);
                driver = new EdgeDriver(edgeOptions);
                break;
            case SAFARI:
                SafariOptions safariOptions = new SafariOptions(desiredCapabilities);
                driver = new SafariDriver(safariOptions);
                break;
            case OPERA:
                WebDriverManager.operadriver().forceCache().setup();
                OperaOptions operaOptions = new OperaOptions();
                operaOptions = operaOptions.merge(desiredCapabilities);
                driver = new OperaDriver(operaOptions);
                break;
            case PHANTOMJS:
                WebDriverManager.phantomjs().forceCache().setup();
                driver = new PhantomJSDriver(desiredCapabilities);
                break;
            // if the browser is not listed, throw an error
            default:
                throw new InvalidBrowserException(
                        "The selected browser " + browser.getName() + " is not an applicable choice");
        }
        return driver;
    }
272308
public function build(): DisposeBrowserContextRequest
	{
		$instance = new DisposeBrowserContextRequest();
		if ($this->browserContextId === null) {
			throw new BuilderException('Property [browserContextId] is required.');
		}
		$instance->browserContextId = $this->browserContextId;
		return $instance;
	}
1251367
private WebDriver generateIEDriver() throws TechnicalException {
        final String pathWebdriver = DriverFactory.getPath(Driver.IE);
        if (!new File(pathWebdriver).setExecutable(true)) {
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
        }
        logger.info("Generating IE driver ({}) ...", pathWebdriver);

        System.setProperty(Driver.IE.getDriverName(), pathWebdriver);

        final DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
        capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
        capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
        capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
        capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
        capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
        capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        capabilities.setCapability("disable-popup-blocking", true);
        capabilities.setJavascriptEnabled(true);

        setLoggingLevel(capabilities);

        // Proxy configuration
        if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
            capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
        }

        return new InternetExplorerDriver(capabilities);
    }
519208
public Drawer build() {
        if (mUsed) {
            throw new RuntimeException("you must not reuse a DrawerBuilder builder");
        }
        if (mActivity == null) {
            throw new RuntimeException("please pass an activity");
        }

        //set that this builder was used. now you have to create a new one
        mUsed = true;

        // if the user has not set a drawerLayout use the default one :D
        if (mDrawerLayout == null) {
            withDrawerLayout(-1);
        }

        //some new Materialize magic ;)
        mMaterialize = new MaterializeBuilder()
                .withActivity(mActivity)
                .withRootView(mRootView)
                .withFullscreen(mFullscreen)
                .withSystemUIHidden(mSystemUIHidden)
                .withUseScrimInsetsLayout(false)
                .withTransparentStatusBar(mTranslucentStatusBar)
                .withTranslucentNavigationBarProgrammatically(mTranslucentNavigationBarProgrammatically)
                .withContainer(mDrawerLayout)
                .build();

        //handle the navigation stuff of the ActionBarDrawerToggle and the drawer in general
        handleDrawerNavigation(mActivity, false);

        //build the view which will be set to the drawer
        Drawer result = buildView();

        //define id for the sliderLayout
        mSliderLayout.setId(R.id.material_drawer_slider_layout);
        // add the slider to the drawer
        mDrawerLayout.addView(mSliderLayout, 1);

        return result;
    }
336170
public JsonTransformer build() {
		try {
			return new WrappingTransformer(buildPipe());
		} catch(Exception e) {
			throw new RuntimeException("Failed to build pipeline: " + e.getMessage(), e);
		}
	}
885212
public Builder toBuilder() {
		return builder()
			.name(_name)
			.cmt(_comment)
			.desc(_description)
			.src(_source)
			.links(_links)
			.number(_number)
			.points(_points);
	}
782646
public ServiceInstance<T> build()
    {
        return new ServiceInstance<T>(name, id, address, port, sslPort, payload, registrationTimeUTC, serviceType, uriSpec, enabled);
    }
1131250
public String build() {

        final StringBuilder description = new StringBuilder();

        // append occurrences
        description.append(IssueDescriptionUtils.getOccurrencesTableHeader()).append('\n');
        for (final ErrorOccurrence error : occurrences) {
            description.append(IssueDescriptionUtils.getOccurrencesTableLine(error));
            description.append('\n');
        }

        // append stacktrace
        description.append("\n\n");
        description.append("*Stacktrace*").append('\n');
        description.append("<pre class=\"javastacktrace\">");
        description.append(stacktrace.trim()).append("</pre>");

        // append version
        description.append('\n').append(IssueDescriptionUtils.DESCRIPTION_VERSION_TAG);

        return description.toString();
    }
148440
def new_driver(browser_name, *args, **kwargs):
        
        if browser_name == FIREFOX:
            return webdriver.Firefox(*args, **kwargs)

        # elif options['local'] and options['browser_name'] == CHROME:
        #     return webdriver.Chrome(*args, **kwargs)
        #
        # elif options['local'] and options['browser_name'] == IE:
        #     return webdriver.Ie(*args, **kwargs)
        #
        # elif options['local'] and options['browser_name'] == OPERA:
        #     return webdriver.Opera(*args, **kwargs)

        elif browser_name == PHANTOMJS:
            executable_path = os.path.join(os.path.dirname(__file__), 'phantomjs/executable/phantomjs_64bit')
            driver = webdriver.PhantomJS(executable_path=executable_path, **kwargs)
            driver.set_window_size(1280, 800)  # Set a default because phantom needs it
            return driver

        else:  # remote
            driver = webdriver.Remote(*args, **kwargs)
            return driver
50929
private WebDriver generateGoogleChromeDriver() throws TechnicalException {
        final String pathWebdriver = DriverFactory.getPath(Driver.CHROME);
        if (!new File(pathWebdriver).setExecutable(true)) {
            throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE));
        }
        logger.info("Generating Chrome driver ({}) ...", pathWebdriver);

        System.setProperty(Driver.CHROME.getDriverName(), pathWebdriver);

        final ChromeOptions chromeOptions = new ChromeOptions();
        final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
        capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

        setLoggingLevel(capabilities);

        if (Context.isHeadless()) {
            chromeOptions.addArguments("--headless");
        }

        // Proxy configuration
        if (Context.getProxy().getProxyType() != ProxyType.UNSPECIFIED && Context.getProxy().getProxyType() != ProxyType.AUTODETECT) {
            capabilities.setCapability(CapabilityType.PROXY, Context.getProxy());
        }

        setChromeOptions(capabilities, chromeOptions);

        final String withWhitelistedIps = Context.getWebdriversProperties("withWhitelistedIps");
        if (withWhitelistedIps != null && !"".equals(withWhitelistedIps)) {
            final ChromeDriverService service = new ChromeDriverService.Builder().withWhitelistedIps(withWhitelistedIps).withVerbose(false).build();
            return new ChromeDriver(service, capabilities);
        } else {
            return new ChromeDriver(capabilities);
        }
    }
1070946
protected InternalDriver createDriver( SecurityPlan securityPlan, SessionFactory sessionFactory, MetricsProvider metricsProvider, Config config )
    {
        return new InternalDriver( securityPlan, sessionFactory, metricsProvider, config.logging() );
    }
827237
public RouterConfiguration build() {
        return new RouterConfiguration(routingBuilder.build(), hotRodRouterBuilder.build(), restRouterBuilder.build(), singlePortRouterBuilder.build());
    }