List of usage examples for org.openqa.selenium.remote BrowserType CHROME
String CHROME
To view the source code for org.openqa.selenium.remote BrowserType CHROME.
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 ww w .j av a 2 s .c o m*/ 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.DisplayAwareFirefoxChromeLauncher.java
License:Apache License
public DisplayAwareFirefoxChromeLauncher(Capabilities browserOptions, RemoteControlConfiguration configuration, String sessionId, String browserString) throws InvalidBrowserExecutableException { this(browserOptions, configuration, sessionId, ApplicationRegistry.instance().browserInstallationCache() .locateBrowserInstallation(BrowserType.CHROME, browserString, new CombinedFirefoxLocator())); if (browserInstallation == null) { throw new InvalidBrowserExecutableException("The specified path to the browser executable is invalid."); }//from w w w. j a va 2s . co m }
From source file:com.comcast.magicwand.builders.PhoenixDriverIngredients.java
License:Apache License
/** * Gets browser type required for the test * * @return Name of the browser/*w w w . ja v a2s .c o m*/ */ public String getBrowser() { if (null != this.browserType && !this.browserType.trim().isEmpty()) { return browserType; } switch (getDesktopOS().getType()) { case MAC: this.browserType = BrowserType.SAFARI; break; case WINDOWS: this.browserType = BrowserType.IE; break; default: this.browserType = BrowserType.CHROME; } return browserType; }
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;/* ww w .j a v a 2s. co m*/ 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.builders.PhoenixDriverIngredientsTest.java
License:Apache License
@DataProvider(name = "defaultIngredients") public Iterator<Object[]> osGenerator() { return new ArrayList<Object[]>() { {/*w w w . j a v a 2 s .co m*/ // @formatter:off add(new Object[] { OSType.MAC, BrowserType.SAFARI }); add(new Object[] { OSType.LINUX, BrowserType.CHROME }); add(new Object[] { OSType.WINDOWS, BrowserType.IE }); add(new Object[] { OSType.UNIX, BrowserType.CHROME }); } // @formatter:on }.iterator(); }
From source file:com.comcast.magicwand.builders.PhoenixDriverIngredientsTest.java
License:Apache License
@DataProvider(name = "validation") public Iterator<Object[]> generateValidation() { return new ArrayList<Object[]>() { {/* w ww . j av a2 s. c o m*/ DesktopOS win = new DesktopOS(OSType.WINDOWS); DesktopOS mac = new DesktopOS(OSType.MAC); MobileOS iphone = new MobileOS(OSType.IPHONE); MobileOS ipad = new MobileOS(OSType.IPAD); MobileOS android = new MobileOS(OSType.ANDROID); // desktop os, mobile os, browser type, is null? // @formatter:off add(new Object[] { mac, null, "", true }); add(new Object[] { mac, null, BrowserType.IE, false }); add(new Object[] { win, iphone, null, false }); add(new Object[] { win, ipad, null, false }); add(new Object[] { win, iphone, null, false }); add(new Object[] { win, android, null, false }); add(new Object[] { mac, ipad, BrowserType.CHROME, false }); add(new Object[] { mac, ipad, null, false }); add(new Object[] { mac, ipad, BrowserType.SAFARI, false }); add(new Object[] { mac, android, BrowserType.SAFARI, false }); add(new Object[] { mac, android, BrowserType.CHROME, false }); // @formatter:on } }.iterator(); }
From source file:com.comcast.magicwand.builders.PhoenixDriverIngredientsTest.java
License:Apache License
@Test public void testIngredientsBuilder() { // @formatter:off PhoenixDriverIngredients i = new PhoenixDriverIngredients().addDesktopOS(new DesktopOS(OSType.MAC)) .addBrowser(BrowserType.CHROME); // @formatter:on assertNotNull(i, "Ingredients are valid"); assertEquals(i.getDesktopOS().getType(), OSType.MAC, "Unexpected OS Type"); assertEquals(i.getBrowser(), BrowserType.CHROME, "Unexpected Browser Type"); assertNull(i.getMobileOS(), "Mobile OS should've been null"); }
From source file:com.comcast.magicwand.wizards.AbstractWizard.java
License:Apache License
/** * Creates default desired capabilities based on a device type *//*from w w w.j av a2 s .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.demo.voting.CitrusEndpointConfig.java
License:Apache License
@Bean public SeleniumBrowser browser() { return CitrusEndpoints.selenium().browserType(BrowserType.CHROME).build(); }
From source file:com.consol.citrus.dsl.runner.SeleniumTestRunnerTest.java
License:Apache License
@Test public void testSeleniumBuilder() { when(applicationContextMock.getBean(TestContext.class)) .thenReturn(applicationContext.getBean(TestContext.class)); when(applicationContextMock.getBean(TestActionListeners.class)).thenReturn(new TestActionListeners()); when(applicationContextMock.getBeansOfType(SequenceBeforeTest.class)) .thenReturn(new HashMap<String, SequenceBeforeTest>()); when(applicationContextMock.getBeansOfType(SequenceAfterTest.class)) .thenReturn(new HashMap<String, SequenceAfterTest>()); when(seleniumBrowser.getEndpointConfiguration()).thenReturn(seleniumBrowserConfiguration); when(seleniumBrowserConfiguration.getBrowserType()).thenReturn(BrowserType.CHROME); when(seleniumBrowser.getWebDriver()).thenReturn(webDriver); when(seleniumBrowser.getName()).thenReturn("mockBrowser"); when(applicationContextMock.getBean("mockBrowser", SeleniumBrowser.class)).thenReturn(seleniumBrowser); when(webDriver.navigate()).thenReturn(navigation); when(webDriver.manage()).thenReturn(options); when(webDriver.switchTo()).thenReturn(locator); when(locator.alert()).thenReturn(alert); when(alert.getText()).thenReturn("Hello!"); when(webDriver.findElement(By.id("header"))).thenReturn(element); when(element.getTagName()).thenReturn("h1"); when(element.isEnabled()).thenReturn(true); when(element.isDisplayed()).thenReturn(true); when(webDriver.findElement(By.linkText("Click Me!"))).thenReturn(link); when(link.getTagName()).thenReturn("a"); when(link.isEnabled()).thenReturn(true); when(link.isDisplayed()).thenReturn(true); when(webDriver.findElement(By.linkText("Hover Me!"))).thenReturn(link); when(webDriver.getMouse()).thenReturn(mouse); when(webDriver.getKeyboard()).thenReturn(keyboard); when(link.getCoordinates()).thenReturn(coordinates); when(webDriver.findElement(By.name("username"))).thenReturn(input); when(input.getTagName()).thenReturn("input"); when(input.isEnabled()).thenReturn(true); when(input.isDisplayed()).thenReturn(true); when(webDriver.findElement(By.name("hiddenButton"))).thenReturn(hidden); when(hidden.getTagName()).thenReturn("input"); when(hidden.isEnabled()).thenReturn(true); when(hidden.isDisplayed()).thenReturn(false); when(webDriver.findElement(By.xpath("//input[@type='checkbox']"))).thenReturn(checkbox); when(checkbox.getTagName()).thenReturn("input"); when(checkbox.isEnabled()).thenReturn(true); when(checkbox.isDisplayed()).thenReturn(true); when(checkbox.isSelected()).thenReturn(false); when(webDriver.executeScript(anyString())).thenReturn(Collections.singletonList("This went wrong!")); when(webDriver.findElement(By.className("btn"))).thenReturn(button); when(button.getTagName()).thenReturn("button"); when(button.isEnabled()).thenReturn(false); when(button.isDisplayed()).thenReturn(false); when(button.getText()).thenReturn("Click Me!"); when(button.getAttribute("type")).thenReturn("submit"); when(button.getCssValue("color")).thenReturn("red"); when(seleniumBrowser.getStoredFile("file.txt")).thenReturn("file.txt"); Set<String> windows = new HashSet<>(); windows.add("last_window"); windows.add("new_window"); when(webDriver.getWindowHandles()).thenReturn(Collections.singleton("last_window")).thenReturn(windows); when(webDriver.getWindowHandle()).thenReturn("last_window"); context.setApplicationContext(applicationContextMock); context.setVariable("cssClass", "btn"); MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContextMock, context) { @Override/*from www.j a v a 2s.c o m*/ public void execute() { selenium(action -> action.start(seleniumBrowser)); selenium(action -> action.navigate("http://localhost:9090")); selenium(action -> action.find().element(By.id("header"))); selenium(action -> action.find().element("class-name", "${cssClass}").tagName("button") .enabled(false).displayed(false).text("Click Me!").style("color", "red") .attribute("type", "submit")); selenium(action -> action.click().element(By.linkText("Click Me!"))); selenium(action -> action.hover().element(By.linkText("Hover Me!"))); selenium(action -> action.setInput("Citrus").element(By.name("username"))); selenium(action -> action.checkInput(false).element(By.xpath("//input[@type='checkbox']"))); selenium(action -> action.javascript("alert('Hello!')").errors("This went wrong!")); selenium(action -> action.alert().text("Hello!").accept()); selenium(action -> action.clearCache()); selenium(action -> action.store("classpath:download/file.txt")); selenium(action -> action.getStored("file.txt")); selenium(action -> action.open().window("my_window")); selenium(action -> action.focus().window("my_window")); selenium(action -> action.close().window("my_window")); selenium(action -> action.waitUntil().hidden().element(By.name("hiddenButton"))); selenium(action -> action.stop()); } }; TestCase test = builder.getTestCase(); int actionIndex = 0; Assert.assertEquals(test.getActionCount(), 18); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), StartBrowserAction.class); StartBrowserAction startBrowserAction = (StartBrowserAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(startBrowserAction.getName(), "selenium:start"); Assert.assertNotNull(startBrowserAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), NavigateAction.class); NavigateAction navigateAction = (NavigateAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(navigateAction.getName(), "selenium:navigate"); Assert.assertEquals(navigateAction.getPage(), "http://localhost:9090"); Assert.assertNotNull(navigateAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), FindElementAction.class); FindElementAction findElementAction = (FindElementAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(findElementAction.getName(), "selenium:find"); Assert.assertEquals(findElementAction.getBy(), By.id("header")); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), FindElementAction.class); findElementAction = (FindElementAction) ((DelegatingTestAction) test.getActions().get(actionIndex++)) .getDelegate(); Assert.assertEquals(findElementAction.getName(), "selenium:find"); Assert.assertEquals(findElementAction.getProperty(), "class-name"); Assert.assertEquals(findElementAction.getPropertyValue(), "${cssClass}"); Assert.assertEquals(findElementAction.getTagName(), "button"); Assert.assertEquals(findElementAction.getText(), "Click Me!"); Assert.assertFalse(findElementAction.isEnabled()); Assert.assertFalse(findElementAction.isDisplayed()); Assert.assertEquals(findElementAction.getStyles().size(), 1L); Assert.assertEquals(findElementAction.getStyles().get("color"), "red"); Assert.assertEquals(findElementAction.getAttributes().size(), 1L); Assert.assertEquals(findElementAction.getAttributes().get("type"), "submit"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), ClickAction.class); ClickAction clickAction = (ClickAction) ((DelegatingTestAction) test.getActions().get(actionIndex++)) .getDelegate(); Assert.assertEquals(clickAction.getName(), "selenium:click"); Assert.assertEquals(clickAction.getBy(), By.linkText("Click Me!")); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), HoverAction.class); HoverAction hoverAction = (HoverAction) ((DelegatingTestAction) test.getActions().get(actionIndex++)) .getDelegate(); Assert.assertEquals(hoverAction.getName(), "selenium:hover"); Assert.assertEquals(hoverAction.getBy(), By.linkText("Hover Me!")); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), SetInputAction.class); SetInputAction setInputAction = (SetInputAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(setInputAction.getName(), "selenium:set-input"); Assert.assertEquals(setInputAction.getBy(), By.name("username")); Assert.assertEquals(setInputAction.getValue(), "Citrus"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), CheckInputAction.class); CheckInputAction checkInputAction = (CheckInputAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(checkInputAction.getName(), "selenium:check-input"); Assert.assertEquals(checkInputAction.getBy(), By.xpath("//input[@type='checkbox']")); Assert.assertFalse(checkInputAction.isChecked()); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), JavaScriptAction.class); JavaScriptAction javaScriptAction = (JavaScriptAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(javaScriptAction.getName(), "selenium:javascript"); Assert.assertEquals(javaScriptAction.getScript(), "alert('Hello!')"); Assert.assertEquals(javaScriptAction.getExpectedErrors().size(), 1L); Assert.assertEquals(javaScriptAction.getExpectedErrors().get(0), "This went wrong!"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), AlertAction.class); AlertAction alertAction = (AlertAction) ((DelegatingTestAction) test.getActions().get(actionIndex++)) .getDelegate(); Assert.assertEquals(alertAction.getName(), "selenium:alert"); Assert.assertEquals(alertAction.getText(), "Hello!"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), ClearBrowserCacheAction.class); ClearBrowserCacheAction clearBrowserCacheAction = (ClearBrowserCacheAction) ((DelegatingTestAction) test .getActions().get(actionIndex++)).getDelegate(); Assert.assertEquals(clearBrowserCacheAction.getName(), "selenium:clear-cache"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), StoreFileAction.class); StoreFileAction storeFileAction = (StoreFileAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(storeFileAction.getName(), "selenium:store-file"); Assert.assertEquals(storeFileAction.getFilePath(), "classpath:download/file.txt"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), GetStoredFileAction.class); GetStoredFileAction getStoredFileAction = (GetStoredFileAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(getStoredFileAction.getName(), "selenium:get-stored-file"); Assert.assertEquals(getStoredFileAction.getFileName(), "file.txt"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), OpenWindowAction.class); OpenWindowAction openWindowAction = (OpenWindowAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(openWindowAction.getName(), "selenium:open-window"); Assert.assertEquals(openWindowAction.getWindowName(), "my_window"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), SwitchWindowAction.class); SwitchWindowAction switchWindowAction = (SwitchWindowAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(switchWindowAction.getName(), "selenium:switch-window"); Assert.assertEquals(switchWindowAction.getWindowName(), "my_window"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), CloseWindowAction.class); CloseWindowAction closeWindowAction = (CloseWindowAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(closeWindowAction.getName(), "selenium:close-window"); Assert.assertEquals(closeWindowAction.getWindowName(), "my_window"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), WaitUntilAction.class); WaitUntilAction waitUntilAction = (WaitUntilAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(waitUntilAction.getName(), "selenium:wait"); Assert.assertEquals(waitUntilAction.getBy(), By.name("hiddenButton")); Assert.assertEquals(waitUntilAction.getCondition(), "hidden"); Assert.assertNotNull(findElementAction.getBrowser()); Assert.assertEquals(((DelegatingTestAction) test.getActions().get(actionIndex)).getDelegate().getClass(), StopBrowserAction.class); StopBrowserAction stopBrowserAction = (StopBrowserAction) ((DelegatingTestAction) test.getActions() .get(actionIndex++)).getDelegate(); Assert.assertEquals(stopBrowserAction.getName(), "selenium:stop"); Assert.assertNotNull(stopBrowserAction.getBrowser()); Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_ALERT_TEXT), "Hello!"); Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_DOWNLOAD_FILE), "file.txt"); Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW), "last_window"); Assert.assertEquals(context.getVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW), "new_window"); Assert.assertEquals(context.getVariable("my_window"), "new_window"); verify(alert).accept(); verify(options).deleteAllCookies(); verify(link).click(); verify(input).clear(); verify(input).sendKeys("Citrus"); }