private WebDriver generateFirefoxDriver ( ) throws TechnicalException { final String pathWebdriver = DriverFactory . getPath ( Driver . FIREFOX ) ; if ( ! new File ( pathWebdriver ) . setExecutable ( true ) ) { throw new TechnicalException ( Messages . getMessage ( TechnicalException . TECHNICAL_ERROR_MESSAGE_WEBDRIVER_SET_EXECUTABLE ) ) ; } logger . info ( "Generating Firefox driver ({}) ..." , pathWebdriver ) ; System . setProperty ( Driver . FIREFOX . getDriverName ( ) , pathWebdriver ) ; final FirefoxOptions firefoxOptions = new FirefoxOptions ( ) ; final FirefoxBinary firefoxBinary = new FirefoxBinary ( ) ; final DesiredCapabilities capabilities = DesiredCapabilities . firefox ( ) ; capabilities . setCapability ( CapabilityType . ForSeleniumServer . ENSURING_CLEAN_SESSION , true ) ; capabilities . setCapability ( CapabilityType . UNEXPECTED_ALERT_BEHAVIOUR , UnexpectedAlertBehaviour . ACCEPT ) ; setLoggingLevel ( capabilities ) ; // Proxy configuration if ( Context . getProxy ( ) . getProxyType ( ) != ProxyType . UNSPECIFIED && Context . getProxy ( ) . getProxyType ( ) != ProxyType . AUTODETECT ) { capabilities . setCapability ( CapabilityType . PROXY , Context . getProxy ( ) ) ; } if ( Context . isHeadless ( ) ) { firefoxBinary . addCommandLineOptions ( "--headless" ) ; firefoxOptions . setBinary ( firefoxBinary ) ; } firefoxOptions . setLogLevel ( Level . OFF ) ; capabilities . setCapability ( FirefoxOptions . FIREFOX_OPTIONS , firefoxOptions ) ; return new FirefoxDriver ( capabilities ) ; }
Generates a firefox webdriver .