List of usage examples for org.openqa.selenium.remote BrowserType FIREFOX
String FIREFOX
To view the source code for org.openqa.selenium.remote BrowserType FIREFOX.
Click Source Link
From source file:com.ariatemplates.seleniumjavarobot.LocalRobotizedBrowserFactory.java
License:Apache License
public static LocalRobotizedBrowserFactory createRobotizedWebDriverFactory(String browser) { if (BrowserType.FIREFOX.equalsIgnoreCase(browser)) { FirefoxProfile firefoxProfile = null; String firefoxProfileProperty = System.getProperty("webdriver.firefox.profile"); if (firefoxProfileProperty == null) { ProfilesIni allProfiles = new ProfilesIni(); // Use the default profile to make extensions available, // and especially to ease debugging with Firebug firefoxProfile = allProfiles.getProfile("default"); }//from w w w.ja va 2s . c om return new LocalFirefox(firefoxProfile); } else if (BrowserType.SAFARI.equalsIgnoreCase(browser)) { return new LocalSafari(); } else if (BrowserType.CHROME.equalsIgnoreCase(browser)) { return new LocalBrowser<ChromeDriver>(ChromeDriver.class); } else if ("chrome-debug".equalsIgnoreCase(browser)) { return new LocalDebuggableChrome(); } else if (BrowserType.IE.equalsIgnoreCase(browser)) { return new LocalBrowser<InternetExplorerDriver>(InternetExplorerDriver.class); } else { throw new RuntimeException("Unknown browser value: " + browser); } }
From source file:com.atlassian.selenium.browsers.firefox.DisplayAwareFirefoxLauncher.java
License:Apache License
public DisplayAwareFirefoxLauncher(Capabilities browserOptions, RemoteControlConfiguration configuration, String sessionId, String browserLaunchLocation) throws InvalidBrowserExecutableException { String browserName = BrowserType.FIREFOX; BrowserLocator locator = new CombinedFirefoxLocator(); String version = (String) browserOptions.getCapability(CapabilityType.VERSION); if ("2".equals(version)) { browserName = BrowserType.FIREFOX_2; locator = new Firefox2Locator(); }//from ww w.ja v a 2 s . c o m if ("3".equals(version)) { browserName = BrowserType.FIREFOX_3; locator = new Firefox3Locator(); } String mode = (String) browserOptions.getCapability("mode"); if (mode == null) { mode = "chrome"; } if ("default".equals(mode)) { mode = "chrome"; } BrowserInstallation installation = ApplicationRegistry.instance().browserInstallationCache() .locateBrowserInstallation(browserName, browserLaunchLocation, locator); if (installation == null) { throw new InvalidBrowserExecutableException("The specified path to the browser executable is invalid."); } if ("chrome".equals(mode)) { realLauncher = new DisplayAwareFirefoxChromeLauncher(browserOptions, configuration, sessionId, installation); return; } boolean proxyInjectionMode = browserOptions.is("proxyInjectionMode") || "proxyInjection".equals(mode); // You can't just individually configure a browser for PI mode; it's a server-level // configuration parameter boolean globalProxyInjectionMode = configuration.getProxyInjectionModeArg(); if (proxyInjectionMode && !globalProxyInjectionMode) { if (proxyInjectionMode) { throw new RuntimeException( "You requested proxy injection mode, but this server wasn't configured with -proxyInjectionMode on the command line"); } } // if user didn't request PI, but the server is configured that way, just switch up to PI proxyInjectionMode = globalProxyInjectionMode; if (proxyInjectionMode) { realLauncher = new ProxyInjectionFirefoxCustomProfileLauncher(browserOptions, configuration, sessionId, installation); return; } // the mode isn't "chrome" or "proxyInjection"; at this point it had better be // CapabilityType.PROXY if (!CapabilityType.PROXY.equals(mode)) { throw new RuntimeException("Unrecognized browser mode: " + mode); } realLauncher = new FirefoxCustomProfileLauncher(browserOptions, configuration, sessionId, installation); }
From source file:com.comcast.magicwand.builders.PhoenixDriverIngredientsTest.java
License:Apache License
@DataProvider(name = "Configurations") public Object[][] generateMacConfigs() { DesktopOS mac = new DesktopOS(OSType.MAC); DesktopOS linux = new DesktopOS(OSType.LINUX); DesktopOS win = new DesktopOS(OSType.WINDOWS); MobileOS iphone = new MobileOS(OSType.IPHONE); MobileOS android = new MobileOS(OSType.ANDROID); OSType expectedOS;//from ww w. ja va2 s . com DesktopOS dynamicOS; String dynamicBrowser; if (SystemDetail.deviceIsLinux()) { expectedOS = OSType.LINUX; dynamicOS = linux; dynamicBrowser = BrowserType.CHROME; } else if (SystemDetail.deviceIsRunningMac()) { expectedOS = OSType.MAC; dynamicOS = mac; dynamicBrowser = BrowserType.SAFARI; } else if (SystemDetail.deviceIsRunningWindows()) { expectedOS = OSType.WINDOWS; dynamicOS = win; dynamicBrowser = BrowserType.IE; } else { expectedOS = null; dynamicBrowser = null; dynamicOS = null; } return new Object[][] { // fields are: // Desktop OS, Mobile OS, Browser Type, expected OS, expected Mobile, expected browser // @formatter:off new Object[] { dynamicOS, null, null, expectedOS, null, dynamicBrowser }, new Object[] { mac, null, null, OSType.MAC, null, BrowserType.SAFARI }, new Object[] { mac, null, BrowserType.FIREFOX, OSType.MAC, null, BrowserType.FIREFOX }, new Object[] { mac, iphone, BrowserType.SAFARI, OSType.MAC, OSType.IPHONE, BrowserType.SAFARI }, new Object[] { mac, android, BrowserType.CHROME, OSType.MAC, OSType.ANDROID, BrowserType.CHROME }, new Object[] { linux, null, null, OSType.LINUX, null, BrowserType.CHROME }, new Object[] { win, null, null, OSType.WINDOWS, null, BrowserType.IE } // @formatter:on }; }
From source file:com.comcast.magicwand.wizards.AbstractWizard.java
License:Apache License
/** * Creates default desired capabilities based on a device type *//*from w ww. ja v a2s . c o m*/ protected void createCapabilities() { DesiredCapabilities curCaps = null; if (isMobile()) { OSType mos = this.mobileOS.getType(); switch (mos) { case ANDROID: curCaps = DesiredCapabilities.android(); break; case IPAD: curCaps = DesiredCapabilities.ipad(); break; case IPHONE: curCaps = DesiredCapabilities.iphone(); break; default: // nothing to do here break; } } else { if (BrowserType.FIREFOX.equals(browserType)) { curCaps = DesiredCapabilities.firefox(); } else if (BrowserType.SAFARI.equals(browserType)) { curCaps = DesiredCapabilities.safari(); } else if (BrowserType.IE.equals(browserType)) { curCaps = DesiredCapabilities.internetExplorer(); } else if (BrowserType.CHROME.equals(browserType)) { curCaps = DesiredCapabilities.chrome(); } } // we need to iterate over each capability because // method DesiredCapabilities#merge is invoking // HashMap#putAll method which overwrites entries DesiredCapabilities iDc = ingredients.getDriverCapabilities(); for (Entry<String, ?> cap : curCaps.asMap().entrySet()) { if (null == iDc.getCapability(cap.getKey())) { iDc.setCapability(cap.getKey(), cap.getValue()); } } }
From source file:com.consol.citrus.selenium.config.annotation.SeleniumBrowserConfigParserTest.java
License:Apache License
@Test public void testSeleniumBrowserParser() { CitrusAnnotations.injectEndpoints(this, context); // 1st browser Assert.assertNotNull(browser1);/*from w w w .j a va 2 s.c o m*/ Assert.assertEquals(browser1.getEndpointConfiguration().getBrowserType(), BrowserType.HTMLUNIT); Assert.assertNull(browser1.getEndpointConfiguration().getStartPageUrl()); Assert.assertTrue(browser1.getEndpointConfiguration().getEventListeners().isEmpty()); Assert.assertEquals(browser1.getEndpointConfiguration().isJavaScript(), true); Assert.assertNull(browser1.getEndpointConfiguration().getWebDriver()); Assert.assertNotNull(browser1.getEndpointConfiguration().getFirefoxProfile()); Assert.assertNull(browser1.getEndpointConfiguration().getRemoteServerUrl()); Assert.assertEquals(browser1.getEndpointConfiguration().getTimeout(), 5000L); // 2nd browser Assert.assertNotNull(browser2); Assert.assertEquals(browser2.getEndpointConfiguration().getBrowserType(), BrowserType.FIREFOX); Assert.assertEquals(browser2.getEndpointConfiguration().getStartPageUrl(), "http://citrusframework.org"); Assert.assertEquals(browser2.getEndpointConfiguration().getEventListeners().size(), 1L); Assert.assertEquals(browser2.getEndpointConfiguration().getEventListeners().get(0), eventListener); Assert.assertEquals(browser2.getEndpointConfiguration().getWebDriver(), webDriver); Assert.assertEquals(browser2.getEndpointConfiguration().getFirefoxProfile(), firefoxProfile); Assert.assertEquals(browser2.getEndpointConfiguration().isJavaScript(), false); Assert.assertNull(browser2.getEndpointConfiguration().getRemoteServerUrl()); Assert.assertEquals(browser2.getEndpointConfiguration().getTimeout(), 10000L); // 3rd browser Assert.assertNotNull(browser3); Assert.assertEquals(browser3.getEndpointConfiguration().getBrowserType(), BrowserType.IE); Assert.assertEquals(browser3.getEndpointConfiguration().getRemoteServerUrl(), "http://localhost:9090/selenium"); }
From source file:com.consol.citrus.selenium.config.xml.SeleniumBrowserParserTest.java
License:Apache License
@Test public void testBrowserParser() { Map<String, SeleniumBrowser> browsers = beanDefinitionContext.getBeansOfType(SeleniumBrowser.class); Assert.assertEquals(browsers.size(), 3); // 1st browser SeleniumBrowser browser = browsers.get("htmlUnitBrowser"); Assert.assertEquals(browser.getEndpointConfiguration().getBrowserType(), BrowserType.HTMLUNIT); Assert.assertNull(browser.getEndpointConfiguration().getStartPageUrl()); Assert.assertTrue(browser.getEndpointConfiguration().getEventListeners().isEmpty()); Assert.assertEquals(browser.getEndpointConfiguration().isJavaScript(), true); Assert.assertNull(browser.getEndpointConfiguration().getWebDriver()); Assert.assertNotNull(browser.getEndpointConfiguration().getFirefoxProfile()); Assert.assertNull(browser.getEndpointConfiguration().getRemoteServerUrl()); Assert.assertEquals(browser.getEndpointConfiguration().getTimeout(), 5000L); // 2nd browser browser = browsers.get("firefoxBrowser"); Assert.assertEquals(browser.getEndpointConfiguration().getBrowserType(), BrowserType.FIREFOX); Assert.assertEquals(browser.getEndpointConfiguration().getStartPageUrl(), "http://citrusframework.org"); Assert.assertEquals(browser.getEndpointConfiguration().getEventListeners().size(), 1L); Assert.assertEquals(browser.getEndpointConfiguration().getEventListeners().get(0), beanDefinitionContext.getBean("eventListener")); Assert.assertEquals(browser.getEndpointConfiguration().getWebDriver(), beanDefinitionContext.getBean("webDriver")); Assert.assertEquals(browser.getEndpointConfiguration().getFirefoxProfile(), beanDefinitionContext.getBean("firefoxProfile")); Assert.assertEquals(browser.getEndpointConfiguration().isJavaScript(), false); Assert.assertNull(browser.getEndpointConfiguration().getRemoteServerUrl()); Assert.assertEquals(browser.getEndpointConfiguration().getTimeout(), 10000L); // 3rd browser browser = browsers.get("remoteBrowser"); Assert.assertEquals(browser.getEndpointConfiguration().getBrowserType(), BrowserType.IE); Assert.assertEquals(browser.getEndpointConfiguration().getRemoteServerUrl(), "http://localhost:9090/selenium"); }
From source file:com.consol.citrus.selenium.endpoint.SeleniumBrowser.java
License:Apache License
/** * Creates local web driver.// ww w. j a v a 2 s.co m * @param browserType * @return */ private WebDriver createLocalWebDriver(String browserType) { switch (browserType) { case BrowserType.FIREFOX: FirefoxProfile firefoxProfile = getEndpointConfiguration().getFirefoxProfile(); /* set custom download folder */ firefoxProfile.setPreference("browser.download.dir", temporaryStorage.toFile().getAbsolutePath()); DesiredCapabilities defaults = DesiredCapabilities.firefox(); defaults.setCapability(FirefoxDriver.PROFILE, firefoxProfile); return new FirefoxDriver(defaults); case BrowserType.IE: return new InternetExplorerDriver(); case BrowserType.EDGE: return new EdgeDriver(); case BrowserType.SAFARI: return new SafariDriver(); case BrowserType.CHROME: return new ChromeDriver(); case BrowserType.GOOGLECHROME: return new ChromeDriver(); case BrowserType.HTMLUNIT: BrowserVersion browserVersion = null; if (getEndpointConfiguration().getVersion().equals("FIREFOX")) { browserVersion = BrowserVersion.FIREFOX_45; } else if (getEndpointConfiguration().getVersion().equals("INTERNET_EXPLORER")) { browserVersion = BrowserVersion.INTERNET_EXPLORER; } else if (getEndpointConfiguration().getVersion().equals("EDGE")) { browserVersion = BrowserVersion.EDGE; } else if (getEndpointConfiguration().getVersion().equals("CHROME")) { browserVersion = BrowserVersion.CHROME; } HtmlUnitDriver htmlUnitDriver; if (browserVersion != null) { htmlUnitDriver = new HtmlUnitDriver(browserVersion); } else { htmlUnitDriver = new HtmlUnitDriver(); } htmlUnitDriver.setJavascriptEnabled(getEndpointConfiguration().isJavaScript()); return htmlUnitDriver; default: throw new CitrusRuntimeException("Unsupported local browser type: " + browserType); } }
From source file:com.consol.citrus.selenium.endpoint.SeleniumBrowser.java
License:Apache License
/** * Creates remote web driver.// ww w . j a va2s . c om * @param browserType * @param serverAddress * @return * @throws MalformedURLException */ private RemoteWebDriver createRemoteWebDriver(String browserType, String serverAddress) { try { switch (browserType) { case BrowserType.FIREFOX: DesiredCapabilities defaultsFF = DesiredCapabilities.firefox(); defaultsFF.setCapability(FirefoxDriver.PROFILE, getEndpointConfiguration().getFirefoxProfile()); return new RemoteWebDriver(new URL(serverAddress), defaultsFF); case BrowserType.IE: DesiredCapabilities defaultsIE = DesiredCapabilities.internetExplorer(); defaultsIE.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); return new RemoteWebDriver(new URL(serverAddress), defaultsIE); case BrowserType.CHROME: DesiredCapabilities defaultsChrome = DesiredCapabilities.chrome(); defaultsChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); return new RemoteWebDriver(new URL(serverAddress), defaultsChrome); case BrowserType.GOOGLECHROME: DesiredCapabilities defaultsGoogleChrome = DesiredCapabilities.chrome(); defaultsGoogleChrome.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); return new RemoteWebDriver(new URL(serverAddress), defaultsGoogleChrome); default: throw new CitrusRuntimeException("Unsupported remote browser type: " + browserType); } } catch (MalformedURLException e) { throw new CitrusRuntimeException("Failed to access remote server", e); } }
From source file:com.consol.citrus.selenium.endpoint.SeleniumEndpointComponentTest.java
License:Apache License
@Test public void testCreateBrowserEndpoint() throws Exception { SeleniumEndpointComponent component = new SeleniumEndpointComponent(); Endpoint endpoint = component.createEndpoint("selenium:browser", context); Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getBrowserType(), BrowserType.HTMLUNIT);/*from ww w .ja v a 2 s . c o m*/ endpoint = component.createEndpoint("selenium:firefox", context); Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getBrowserType(), BrowserType.FIREFOX); Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
From source file:com.gargoylesoftware.htmlunit.WebDriverTestCase.java
License:Apache License
private static String getBrowserName(final BrowserVersion browserVersion) { if (browserVersion == BrowserVersion.FIREFOX_45) { return BrowserType.FIREFOX + '-' + browserVersion.getBrowserVersionNumeric(); } else if (browserVersion == BrowserVersion.FIREFOX_52) { return BrowserType.FIREFOX; }/*from w ww.j a va2 s .c o m*/ if (browserVersion == BrowserVersion.INTERNET_EXPLORER) { return BrowserType.IE; } if (browserVersion == BrowserVersion.EDGE) { return BrowserType.EDGE; } return BrowserType.CHROME; }