List of usage examples for org.openqa.selenium.remote BrowserType HTMLUNIT
String HTMLUNIT
To view the source code for org.openqa.selenium.remote BrowserType HTMLUNIT.
Click Source Link
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 v a2 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.//w w w. j a v a 2 s . c o 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.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); endpoint = component.createEndpoint("selenium:firefox", context); Assert.assertEquals(endpoint.getClass(), SeleniumBrowser.class); Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getBrowserType(), BrowserType.FIREFOX);//from ww w. ja v a 2s. c o m Assert.assertEquals(((SeleniumBrowser) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
From source file:com.gargoylesoftware.htmlunit.WebDriverTestCase.java
License:Apache License
/** * Builds a new WebDriver instance.// ww w . ja va 2 s.c om * @return the instance * @throws IOException in case of exception */ protected WebDriver buildWebDriver() throws IOException { if (useRealBrowser()) { if (getBrowserVersion().isIE()) { if (IE_BIN_ != null) { System.setProperty("webdriver.ie.driver", IE_BIN_); } return new InternetExplorerDriver(); } if (BrowserVersion.CHROME == getBrowserVersion()) { if (CHROME_SERVICE_ == null) { final ChromeDriverService.Builder builder = new ChromeDriverService.Builder(); if (CHROME_BIN_ != null) { builder.usingDriverExecutable(new File(CHROME_BIN_)); } CHROME_SERVICE_ = builder.usingAnyFreePort().build(); CHROME_SERVICE_.start(); } return new ChromeDriver(CHROME_SERVICE_); } if (BrowserVersion.EDGE == getBrowserVersion()) { if (EDGE_BIN_ != null) { System.setProperty("webdriver.edge.driver", EDGE_BIN_); } return new EdgeDriver(); } if (BrowserVersion.FIREFOX_45 == getBrowserVersion()) { // disable the new marionette interface because it requires ff47 or more System.setProperty("webdriver.firefox.marionette", "false"); if (FF45_BIN_ != null) { final FirefoxOptions options = new FirefoxOptions(); options.setBinary(FF45_BIN_); return new FirefoxDriver(options); } return new FirefoxDriver(); } if (BrowserVersion.FIREFOX_52 == getBrowserVersion()) { if (FF52_BIN_ != null) { final FirefoxOptions options = new FirefoxOptions(); options.setBinary(FF52_BIN_); return new FirefoxDriver(options); } return new FirefoxDriver(); } throw new RuntimeException("Unexpected BrowserVersion: " + getBrowserVersion()); } if (webDriver_ == null) { final DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setBrowserName(BrowserType.HTMLUNIT); capabilities.setVersion(getBrowserName(getBrowserVersion())); webDriver_ = new HtmlUnitDriver(capabilities); } return webDriver_; }
From source file:eu.tuxoo.test.JQueryLoadingTest.java
License:Apache License
private HtmlUnitDriver createDriver(final CollectingAlertHandler alertHandler, final String browserVersion, final StringWebResponse... mockResponses) { DesiredCapabilities dc = new DesiredCapabilities(); dc.setBrowserName(BrowserType.HTMLUNIT); dc.setVersion(browserVersion);//from w ww. jav a2s.com return new HtmlUnitDriver(dc) { @Override protected WebClient modifyWebClient(WebClient client) { client.setAlertHandler(alertHandler); client.setWebConnection(new DelegatingWebConnection(new HttpWebConnection(client), mockResponses)); client.getOptions().setJavaScriptEnabled(true); return client; } }; }