List of usage examples for org.openqa.selenium Platform MAC
Platform MAC
To view the source code for org.openqa.selenium Platform MAC.
Click Source Link
From source file:com.seleniumtests.ut.browserfactory.TestSafariCapabilityFactory.java
License:Apache License
@BeforeMethod(groups = { "ut" }) public void init() { PowerMockito.mockStatic(System.class); PowerMockito.when(System.getProperty(anyString())).thenCallRealMethod(); PowerMockito.when(System.setProperty(anyString(), anyString())).thenCallRealMethod(); PowerMockito.when(System.clearProperty(anyString())).thenCallRealMethod(); PowerMockito.when(System.getProperty("os.name")).thenReturn("Mac OS X"); Map<BrowserType, List<BrowserInfo>> browserInfos = new HashMap<>(); browserInfos.put(BrowserType.SAFARI, Arrays.asList(new BrowserInfo(BrowserType.SAFARI, "7.2", "", false))); PowerMockito.mockStatic(OSUtility.class); PowerMockito.when(OSUtility.getInstalledBrowsersWithVersion()).thenReturn(browserInfos); PowerMockito.when(OSUtility.getCurrentPlatorm()).thenReturn(Platform.MAC); PowerMockito.mockStatic(OSUtilityFactory.class); PowerMockito.when(OSUtilityFactory.getInstance()).thenReturn(osUtility); when(osUtility.getProgramExtension()).thenReturn(".exe"); Mockito.when(config.getDebug()).thenReturn(Arrays.asList(DebugMode.NONE)); }
From source file:com.seleniumtests.ut.browserfactory.TestSafariCapabilityFactory.java
License:Apache License
@Test(groups = { "ut" }) public void testCreateDefaultCapabilitiesWithPlatform() { Mockito.when(config.isEnableJavascript()).thenReturn(true); Mockito.when(config.getProxy()).thenReturn(proxyConfig); Mockito.when(config.getWebPlatform()).thenReturn(Platform.MAC); MutableCapabilities capa = new SafariCapabilitiesFactory(config).createCapabilities(); Assert.assertEquals(capa.getPlatform(), Platform.MAC); }
From source file:com.seleniumtests.util.osutility.OSUtility.java
License:Apache License
/****************************************** *********** OS information *************** ******************************************/ public static Platform getCurrentPlatorm() { if (isWindows()) { return Platform.WINDOWS; } else if (isLinux()) { return Platform.LINUX; } else if (isMac()) { return Platform.MAC; } else {//from w ww .java2s . co m throw new ConfigurationException(getOSName() + " is not recognized as a valid platform"); } }
From source file:com.vaadin.testbench.parallel.BrowserUtil.java
/** * Returns a human readable identifier of the platform described by the * given capabilities. Used mainly for screenshots * * @param capabilities//from ww w . j av a 2s .c om * @return a human readable string describing the platform */ public static String getPlatform(Capabilities capabilities) { if (capabilities == null) { return "Unknown"; } try { Platform p = capabilities.getPlatform(); if (p == Platform.WIN8 || p == Platform.WINDOWS || p == Platform.VISTA || p == Platform.XP) { return "Windows"; } else if (p == Platform.MAC) { return "Mac"; } } catch (Exception e) { } Object rawPlatform = capabilities.getCapability(CapabilityType.PLATFORM); if (rawPlatform == null) { return "Unknown"; } return rawPlatform.toString(); }
From source file:com.vaadin.testbench.screenshot.ReferenceNameGeneratorTest.java
@Test public void testGenerateName_fooSafari5inCapabilities_returnsGeneratedName() { Capabilities safari = createNiceMock(Capabilities.class); expect(safari.getPlatform()).andReturn(Platform.MAC); expect(safari.getBrowserName()).andReturn("Safari"); expect(safari.getVersion()).andReturn("5"); replay(safari);//from w w w . j a v a 2s .c o m String name = rng.generateName("foo", safari); assertEquals("foo_mac_Safari_5", name); verify(safari); }
From source file:com.vaadin.testbench.screenshot.ReferenceNameGeneratorTest.java
@Test public void testGenerateName_barPhantomJSinCapabilities_returnsGeneratedName() { Capabilities phantom = createNiceMock(Capabilities.class); expect(phantom.getPlatform()).andReturn(Platform.MAC); expect(phantom.getBrowserName()).andReturn("phantomjs"); expect(phantom.getVersion()).andReturn("phantomjs-1.8.1+ghostdriver-1.0.2"); replay(phantom);//from ww w . j a v a 2s . co m String name = rng.generateName("bar", phantom); assertEquals("bar_mac_phantomjs_1", name); verify(phantom); }
From source file:com.zaizi.automation.alfresco.core.info.TestCaseProperties.java
License:Open Source License
public static WebDriver gridDriver(String browser, String operatingSystem) throws MalformedURLException { if (driver != null) { closeDriver(driver);// w w w .j a v a2 s.c o m } if ("Firefox".equals(browser) && "MAC".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.MAC); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(FFNODEURL), capability); } else if ("Firefox".equals(browser) && "VISTA".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.VISTA); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(FFNODEURL), capability); } else if ("Firefox".equals(browser) && "WINDOWS".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setBrowserName("firefox"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.WINDOWS); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(FFNODEURL), capability); } else if ("Chrome".equals(browser) && "VISTA".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.chrome(); capability.setBrowserName("chrome"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.VISTA); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability); } else if ("Chrome".equals(browser) && "MAC".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.chrome(); capability.setBrowserName("chrome"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.MAC); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability); } else if ("Chrome".equals(browser) && "WINDOWS".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.chrome(); capability.setBrowserName("chrome"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.WINDOWS); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(CHROMENODEURL), capability); } else if ("IE".equals(browser) && "VISTA".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.internetExplorer(); capability.setBrowserName("internet explorer"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.VISTA); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); capability.setCapability("name", "Remote File Upload using Selenium 2's FileDetectors"); driver = new RemoteWebDriver(new URL(IENODEURL), capability); } else if ("IE".equals(browser) && "WINDOWS".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.internetExplorer(); capability.setBrowserName("internet explorer"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.WINDOWS); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(IENODEURL), capability); } else if ("Safari".equals(browser) && "MAC".equals(operatingSystem)) { DesiredCapabilities capability = DesiredCapabilities.safari(); capability.setBrowserName("safari"); capability.setCapability("ignoreZoomSetting", true); capability.setPlatform(Platform.MAC); capability.setVersion("ANY"); capability.setCapability("nativeEvents", false); driver = new RemoteWebDriver(new URL(IENODEURL), capability); } return driver; }
From source file:io.appium.java_client.localserver.ServerBuilderTest.java
License:Apache License
private static File findCustomNode() { Platform current = Platform.getCurrent(); if (current.is(Platform.WINDOWS)) return new File(String.valueOf(properties.get("path.to.custom.node.win"))); if (current.is(Platform.MAC)) return new File(String.valueOf(properties.get("path.to.custom.node.macos"))); return new File(String.valueOf(properties.get("path.to.custom.node.linux"))); }
From source file:org.cerberus.engine.execution.impl.SeleniumServerService.java
License:Open Source License
@Override public void startServer(TestCaseExecution tCExecution) throws CerberusException { //message used for log purposes String logPrefix = "[" + tCExecution.getTest() + " - " + tCExecution.getTestCase() + "] "; try {/*w w w. j av a 2 s . c o m*/ LOG.info(logPrefix + "Start Selenium Server"); /** * Set Session */ LOG.debug(logPrefix + "Setting the session."); String system = tCExecution.getApplicationObj().getSystem(); /** * Get the parameters that will be used to set the servers * (selenium/appium) If timeout has been defined at the execution * level, set the selenium & appium wait element with this value, * else, take the one from parameter */ Integer cerberus_selenium_pageLoadTimeout, cerberus_selenium_implicitlyWait, cerberus_selenium_setScriptTimeout, cerberus_selenium_wait_element, cerberus_appium_wait_element; if (!tCExecution.getTimeout().isEmpty()) { cerberus_selenium_wait_element = Integer.valueOf(tCExecution.getTimeout()); cerberus_appium_wait_element = Integer.valueOf(tCExecution.getTimeout()); } else { cerberus_selenium_wait_element = this.getTimeoutSetInParameterTable(system, "cerberus_selenium_wait_element", 90000, logPrefix); cerberus_appium_wait_element = this.getTimeoutSetInParameterTable(system, "cerberus_appium_wait_element", 90000, logPrefix); ; } cerberus_selenium_pageLoadTimeout = this.getTimeoutSetInParameterTable(system, "cerberus_selenium_pageLoadTimeout", 90000, logPrefix); cerberus_selenium_implicitlyWait = this.getTimeoutSetInParameterTable(system, "cerberus_selenium_implicitlyWait", 0, logPrefix); cerberus_selenium_setScriptTimeout = this.getTimeoutSetInParameterTable(system, "cerberus_selenium_setScriptTimeout", 90000, logPrefix); LOG.debug(logPrefix + "TimeOut defined on session : " + cerberus_selenium_wait_element); Session session = new Session(); session.setCerberus_selenium_implicitlyWait(cerberus_selenium_implicitlyWait); session.setCerberus_selenium_pageLoadTimeout(cerberus_selenium_pageLoadTimeout); session.setCerberus_selenium_setScriptTimeout(cerberus_selenium_setScriptTimeout); session.setCerberus_selenium_wait_element(cerberus_selenium_wait_element); session.setCerberus_appium_wait_element(cerberus_appium_wait_element); session.setHost(tCExecution.getSeleniumIP()); session.setPort(tCExecution.getPort()); tCExecution.setSession(session); LOG.debug(logPrefix + "Session is set."); /** * SetUp Capabilities */ LOG.debug(logPrefix + "Set Capabilities"); DesiredCapabilities caps = this.setCapabilities(tCExecution); session.setDesiredCapabilities(caps); LOG.debug(logPrefix + "Set Capabilities - retreived"); /** * SetUp Driver */ LOG.debug(logPrefix + "Set Driver"); WebDriver driver = null; AppiumDriver appiumDriver = null; if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("GUI")) { if (caps.getPlatform().is(Platform.ANDROID)) { appiumDriver = new AndroidDriver(new URL("http://" + tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort() + "/wd/hub"), caps); driver = (WebDriver) appiumDriver; } else if (caps.getPlatform().is(Platform.MAC)) { appiumDriver = new IOSDriver(new URL("http://" + tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort() + "/wd/hub"), caps); driver = (WebDriver) appiumDriver; } else { driver = new RemoteWebDriver(new URL("http://" + tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort() + "/wd/hub"), caps); } } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("APK")) { appiumDriver = new AndroidDriver(new URL("http://" + tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort() + "/wd/hub"), caps); driver = (WebDriver) appiumDriver; } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("IPA")) { appiumDriver = new IOSDriver(new URL("http://" + tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort() + "/wd/hub"), caps); driver = (WebDriver) appiumDriver; } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("FAT")) { sikuliService.doSikuliAction(session, "openApp", null, tCExecution.getCountryEnvironmentParameters().getIp()); } /** * Defining the timeout at the driver level. Only in case of not * Appium Driver (see * https://github.com/vertigo17/Cerberus/issues/754) */ if (driver != null && appiumDriver == null) { driver.manage().timeouts().pageLoadTimeout(cerberus_selenium_pageLoadTimeout, TimeUnit.MILLISECONDS); driver.manage().timeouts().implicitlyWait(cerberus_selenium_implicitlyWait, TimeUnit.MILLISECONDS); driver.manage().timeouts().setScriptTimeout(cerberus_selenium_setScriptTimeout, TimeUnit.MILLISECONDS); } tCExecution.getSession().setDriver(driver); tCExecution.getSession().setAppiumDriver(appiumDriver); /** * If Gui application, maximize window Get IP of Node in case of * remote Server */ if (tCExecution.getApplicationObj().getType().equalsIgnoreCase("GUI") && !caps.getPlatform().equals(Platform.ANDROID)) { driver.manage().window().maximize(); getIPOfNode(tCExecution); /** * If screenSize is defined, set the size of the screen. */ if (!tCExecution.getScreenSize().equals("")) { Integer screenWidth = Integer.valueOf(tCExecution.getScreenSize().split("\\*")[0]); Integer screenLength = Integer.valueOf(tCExecution.getScreenSize().split("\\*")[1]); setScreenSize(driver, screenWidth, screenLength); } tCExecution.setScreenSize(getScreenSize(driver)); } tCExecution.getSession().setStarted(true); } catch (CerberusException exception) { LOG.error(logPrefix + exception.toString()); throw new CerberusException(exception.getMessageError()); } catch (MalformedURLException exception) { LOG.error(logPrefix + exception.toString()); MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_URL_MALFORMED); mes.setDescription(mes.getDescription().replace("%URL%", tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort())); throw new CerberusException(mes); } catch (UnreachableBrowserException exception) { LOG.error(logPrefix + exception.toString()); MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SELENIUM_COULDNOTCONNECT); mes.setDescription(mes.getDescription().replace("%SSIP%", tCExecution.getSeleniumIP())); mes.setDescription(mes.getDescription().replace("%SSPORT%", tCExecution.getSeleniumPort())); throw new CerberusException(mes); } catch (Exception exception) { LOG.error(logPrefix + exception.toString()); MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_SELENIUM); mes.setDescription(mes.getDescription().replace("%MES%", exception.toString())); throw new CerberusException(mes); } }
From source file:org.cerberus.serviceEngine.impl.SeleniumService.java
License:Open Source License
public DesiredCapabilities setCapabilityPlatform(DesiredCapabilities capabilities, String platform) throws CerberusException { if (platform.equalsIgnoreCase("WINDOWS")) { capabilities.setPlatform(Platform.WINDOWS); } else if (platform.equalsIgnoreCase("LINUX")) { capabilities.setPlatform(Platform.LINUX); } else if (platform.equalsIgnoreCase("ANDROID")) { capabilities.setPlatform(Platform.ANDROID); } else if (platform.equalsIgnoreCase("MAC")) { capabilities.setPlatform(Platform.MAC); } else if (platform.equalsIgnoreCase("UNIX")) { capabilities.setPlatform(Platform.UNIX); } else if (platform.equalsIgnoreCase("VISTA")) { capabilities.setPlatform(Platform.VISTA); } else if (platform.equalsIgnoreCase("WIN8")) { capabilities.setPlatform(Platform.WIN8); } else if (platform.equalsIgnoreCase("XP")) { capabilities.setPlatform(Platform.XP); } else {//from www .j a va2 s . c om capabilities.setPlatform(Platform.ANY); } return capabilities; }