src/main/java/com/xceptance/neodymium/module/statement/browser/multibrowser/BrowserRunnerHelper.java
/**
     * Instantiate the {@link WebDriver} according to the configuration read from {@link Browser} annotations.
     * 
     * @param config
     *            {@link BrowserConfiguration} that describes the desired browser instance
     * @return {@link WebDriverStateContainer} the instance of the browser described in {@link BrowserConfiguration} and
     *         in {@link NeodymiumConfiguration}
     * @throws MalformedURLException
     *             if <a href="https://github.com/Xceptance/neodymium-library/wiki/Selenium-grid">Selenium grid</a> is
     *             used and the given grid URL is invalid
     */
Instantiate the  WebDriver according to the configuration read from  Browser annotations.

@param config
BrowserConfiguration that describes the desired browser instance
@return  WebDriverStateContainer the instance of the browser described in  BrowserConfiguration and
in  NeodymiumConfiguration
@throws MalformedURLException
if Selenium grid is
used and the given grid URL is invalid
Instantiate the WebDriver according to the configuration read from Browser annotations . @param config BrowserConfiguration that describes the desired browser instance @return WebDriverStateContainer the instance of the browser described in BrowserConfiguration and in NeodymiumConfiguration @throws MalformedURLException if Selenium grid is used and the given grid URL is invalid
public static WebDriverStateContainer createWebDriverStateContainer(final BrowserConfiguration config) throws MalformedURLException
    {
        final MutableCapabilities capabilities = config.getCapabilities();
        final WebDriverStateContainer wDSC = new WebDriverStateContainer();
        if (Neodymium.configuration().useLocalProxy())
        {
            BrowserUpProxy proxy = setupEmbeddedProxy();
            wDSC.setProxy(proxy);
            capabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(proxy));
        }
        else if (Neodymium.configuration().useProxy())
        {
            capabilities.setCapability(CapabilityType.PROXY, createProxyCapabilities());
        }
        final String testEnvironment = config.getTestEnvironment();
        if (StringUtils.isEmpty(testEnvironment) || "local".equalsIgnoreCase(testEnvironment))
        {
            final String browserName = capabilities.getBrowserName();
            if (chromeBrowsers.contains(browserName))
            {
                final ChromeOptions options = (ChromeOptions) capabilities;
                final String pathToBrowser = Neodymium.configuration().getChromeBrowserPath();
                if (StringUtils.isNotBlank(pathToBrowser))
                {
                    options.setBinary(pathToBrowser);
                }
                options.setHeadless(config.isHeadless());
                if (config.getArguments() != null && config.getArguments().size() > 0)
                {
                    options.addArguments(config.getArguments());
                }
                wDSC.setWebDriver(new ChromeDriver(options));
            }
            else if (firefoxBrowsers.contains(browserName))
            {
                final FirefoxOptions options = new FirefoxOptions();
                options.setBinary(createFirefoxBinary(Neodymium.configuration().getFirefoxBrowserPath()));
                options.merge(capabilities);
                options.setHeadless(config.isHeadless());
                if (config.getArguments() != null && config.getArguments().size() > 0)
                {
                    options.addArguments(config.getArguments());
                }
                wDSC.setWebDriver(new FirefoxDriver(options));
            }
            else if (internetExplorerBrowsers.contains(browserName))
            {
                final InternetExplorerOptions options = new InternetExplorerOptions();
                options.merge(capabilities);
                if (config.getArguments() != null && config.getArguments().size() > 0)
                {
                    for (String argument : config.getArguments())
                    {
                        options.addCommandSwitches(argument);
                    }
                }
                wDSC.setWebDriver(new InternetExplorerDriver(options));
            }
            else if (safariBrowsers.contains(browserName))
            {
                final SafariOptions options = (SafariOptions) capabilities;
                wDSC.setWebDriver(new SafariDriver(options));
            }
            else
            {
                wDSC.setWebDriver(new RemoteWebDriver(capabilities));
            }
        }
        else
        {
            wDSC.setWebDriver(new RemoteWebDriver(createGridExecutor(testEnvironment), capabilities));
        }
        return wDSC;
    }
public static WebDriverStateContainer createWebDriverStateContainer ( final BrowserConfiguration config ) throws MalformedURLException { final MutableCapabilities capabilities = config . getCapabilities ( ) ; final WebDriverStateContainer wDSC = new WebDriverStateContainer ( ) ; if ( Neodymium . configuration ( ) . useLocalProxy ( ) ) { BrowserUpProxy proxy = setupEmbeddedProxy ( ) ; wDSC . setProxy ( proxy ) ; capabilities . setCapability ( CapabilityType . PROXY , ClientUtil . createSeleniumProxy ( proxy ) ) ; } else if ( Neodymium . configuration ( ) . useProxy ( ) ) { capabilities . setCapability ( CapabilityType . PROXY , createProxyCapabilities ( ) ) ; } final String testEnvironment = config . getTestEnvironment ( ) ; if ( StringUtils . isEmpty ( testEnvironment ) || "local" . equalsIgnoreCase ( testEnvironment ) ) { final String browserName = capabilities . getBrowserName ( ) ; if ( chromeBrowsers . contains ( browserName ) ) { final ChromeOptions options = ( ChromeOptions ) capabilities ; final String pathToBrowser = Neodymium . configuration ( ) . getChromeBrowserPath ( ) ; if ( StringUtils . isNotBlank ( pathToBrowser ) ) { options . setBinary ( pathToBrowser ) ; } options . setHeadless ( config . isHeadless ( ) ) ; if ( config . getArguments ( ) != null && config . getArguments ( ) . size ( ) > 0 ) { options . addArguments ( config . getArguments ( ) ) ; } wDSC . setWebDriver ( new ChromeDriver ( options ) ) ; } else if ( firefoxBrowsers . contains ( browserName ) ) { final FirefoxOptions options = new FirefoxOptions ( ) ; options . setBinary ( createFirefoxBinary ( Neodymium . configuration ( ) . getFirefoxBrowserPath ( ) ) ) ; options . merge ( capabilities ) ; options . setHeadless ( config . isHeadless ( ) ) ; if ( config . getArguments ( ) != null && config . getArguments ( ) . size ( ) > 0 ) { options . addArguments ( config . getArguments ( ) ) ; } wDSC . setWebDriver ( new FirefoxDriver ( options ) ) ; } else if ( internetExplorerBrowsers . contains ( browserName ) ) { final InternetExplorerOptions options = new InternetExplorerOptions ( ) ; options . merge ( capabilities ) ; if ( config . getArguments ( ) != null && config . getArguments ( ) . size ( ) > 0 ) { for ( String argument : config . getArguments ( ) ) { options . addCommandSwitches ( argument ) ; } } wDSC . setWebDriver ( new InternetExplorerDriver ( options ) ) ; } else if ( safariBrowsers . contains ( browserName ) ) { final SafariOptions options = ( SafariOptions ) capabilities ; wDSC . setWebDriver ( new SafariDriver ( options ) ) ; } else { wDSC . setWebDriver ( new RemoteWebDriver ( capabilities ) ) ; } } else { wDSC . setWebDriver ( new RemoteWebDriver ( createGridExecutor ( testEnvironment ) , capabilities ) ) ; } return wDSC ; }
Instantiate the {@link WebDriver} according to the configuration read from {@link Browser} annotations.
Instantiate the { @link WebDriver } according to the configuration read from { @link Browser } annotations .
// set the Proxy for later usage // configure the proxy via capabilities // do we have a custom path? // establish connection to target website