List of usage examples for org.openqa.selenium Platform WINDOWS
Platform WINDOWS
To view the source code for org.openqa.selenium Platform WINDOWS.
Click Source Link
From source file:com.opera.core.systems.OperaRunnerSettingsTest.java
License:Apache License
@Test public void testSetDisplay() { Integer display = 8;// ww w. j av a2s .co m Exception unsupportedOperationException = null; try { settings.setDisplay(display); } catch (UnsupportedOperationException e) { unsupportedOperationException = e; } if (Platform.getCurrent() == Platform.WINDOWS) { assertNotNull(unsupportedOperationException); } else if (Platform.getCurrent() == Platform.LINUX || Platform.getCurrent() == Platform.UNIX) { assertNull(unsupportedOperationException); assertEquals(display, settings.getDisplay()); } }
From source file:com.opera.core.systems.OperaRunnerSettingsTest.java
License:Apache License
@Test(expected = WebDriverException.class) public void testSetProfileWithInvalidString() { if (Platform.getCurrent().is(Platform.WINDOWS)) { settings.setProfile(":/this/does/not/exist"); } else {// www.j a v a 2s . c o m settings.setProfile("/this/does/not/exist"); } runner = new TestOperaRunner(settings); }
From source file:com.opera.core.systems.runner.launcher.OperaLauncherBinary.java
License:Apache License
public void init() throws IOException { ProcessBuilder builder = new ProcessBuilder(commands); builder.redirectErrorStream(true);// w w w. j av a 2 s. c o m try { process = builder.start(); watcher = new OutputWatcher(process); outputWatcherThread = new Thread(getThreadGroup(), watcher, "output-watcher"); outputWatcherThread.setDaemon(true); running.set(true); outputWatcherThread.start(); } catch (IOException e) { if (Platform.getCurrent().is(Platform.WINDOWS)) { throw new IOException( "Could not start the launcher process, make sure you have the Microsoft Visual C++ " + "2008 Redistributable Package installed on your system: " + e.getMessage()); } else { throw new IOException(e); } } try { waitFor(OperaIntervals.PROCESS_START_SLEEP.getValue()); if (process.exitValue() > 0) { throw new IOException("exited immediately; possibly incorrect command-line arguments? " + "Commands: " + commands); } } catch (IllegalThreadStateException e) { // process hasn't exited, soldier on! } }
From source file:com.opera.core.systems.testing.Resources.java
License:Apache License
public Resources() throws IOException { if (Platform.getCurrent().is(Platform.WINDOWS)) { executableBinary = new File("C:\\WINDOWS\\system32\\find.exe"); } else {/*from www . ja v a2 s.c o m*/ executableBinary = new File("/bin/echo"); } //temporaryFolder().newFolder(); textFile = temporaryFolder().newFile(); }
From source file:com.photon.phresco.Screens.BaseScreen.java
License:Apache License
public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL, String applicationContext) throws ScreenException, MalformedURLException { URL server = new URL("http://localhost:4444/wd/hub/"); if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) { log.info("-------------***LAUNCHING GOOGLECHROME***--------------"); try {//from www. ja v a 2 s .c o m capabilities = new DesiredCapabilities(); capabilities.setBrowserName("chrome"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) { log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------"); try { capabilities = new DesiredCapabilities(); capabilities.setJavascriptEnabled(true); capabilities.setBrowserName("iexplorer"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) { log.info("-------------***LAUNCHING OPERA***--------------"); try { capabilities = new DesiredCapabilities(); capabilities.setBrowserName("opera"); capabilities.setCapability("opera.autostart ", true); System.out.println("-----------checking the OPERA-------"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_SAFARI)) { log.info("-------------***LAUNCHING SAFARI***--------------"); try { capabilities = new DesiredCapabilities(); capabilities.setBrowserName("safari"); /* capabilities.setCapability("safari.autostart ", true);*/ System.out.println("-----------checking the SAFARI-------"); } catch (Exception e) { e.printStackTrace(); } } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) { log.info("-------------***LAUNCHING FIREFOX***--------------"); capabilities = new DesiredCapabilities(); capabilities.setBrowserName("firefox"); } else if (selectedBrowser.equalsIgnoreCase(Constants.HTML_UNIT_DRIVER)) { log.info("-------------***HTML_UNIT_DRIVER***--------------"); capabilities = new DesiredCapabilities(); capabilities.setBrowserName("htmlunit"); /*URL server = new URL("http://testVM:4444/wd/hub"); new RemoteWebDriver(new Url("http://testVM:4444/wd/hub");*/ System.out.println("-----------checking the HTML_UNIT_DRIVER-------"); // break; // driver = new RemoteWebDriver(server, capabilities); } else { throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------"); } if (selectedPlatform.equalsIgnoreCase("WINDOWS")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.WINDOWS); } else if (selectedPlatform.equalsIgnoreCase("LINUX")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.LINUX); } else if (selectedPlatform.equalsIgnoreCase("MAC")) { capabilities.setCapability(CapabilityType.PLATFORM, Platform.MAC); } driver = new RemoteWebDriver(server, capabilities); driver.get(applicationURL + applicationContext); }
From source file:com.rmn.qa.AutomationRequestMatcherTest.java
License:Open Source License
@Test // Tests that OS NOT matching on a node works correctly public void testRequestNonMatchingOs() throws IOException, ServletException { String browser = "firefox"; Platform os = Platform.LINUX;//from ww w .j a va2 s . c om String nodeId = "nodeId"; // Add a node that is not running to make sure its not included in the available calculation AutomationDynamicNode node = new AutomationDynamicNode("testUuid", nodeId, null, null, new Date(), 50); AutomationContext.getContext().addNode(node); ProxySet proxySet = new ProxySet(false); MockRemoteProxy proxy = new MockRemoteProxy(); proxy.setMaxNumberOfConcurrentTestSessions(50); proxy.setCapabilityMatcher(new AutomationCapabilityMatcher()); Map<String, Object> config = Maps.newHashMap(); config.put(AutomationConstants.INSTANCE_ID, nodeId); proxy.setConfig(config); Map<String, Object> capabilities = Maps.newHashMap(); capabilities.put(CapabilityType.BROWSER_NAME, "firefox"); capabilities.put(CapabilityType.PLATFORM, Platform.WINDOWS); TestSlot testSlot = new TestSlot(proxy, SeleniumProtocol.WebDriver, null, capabilities); proxy.setMultipleTestSlots(testSlot, 10); proxySet.add(proxy); AutomationContext.getContext().setTotalNodeCount(50); int freeThreads = new AutomationRequestMatcher().getNumFreeThreadsForParameters(proxySet, new AutomationRunRequest(null, null, browser, null, os)); Assert.assertEquals("Thread count should be 0 due to non-matching OS", 0, freeThreads); }
From source file:com.rmn.qa.AutomationRunRequestTest.java
License:Open Source License
@Test // Tests that two run request objects do NOT match each other since the optional fields are on the second object public void testDoesntMatchesOtherRunRequestNonOptionalParameters() { String uuid = "testUuid"; String browser = "firefox"; String browserVersion = null; Platform os = Platform.WINDOWS; AutomationRunRequest first = new AutomationRunRequest(uuid, null, browser, "20", Platform.LINUX); AutomationRunRequest second = new AutomationRunRequest(uuid, null, browser, browserVersion, os); Assert.assertFalse("Run requests should match", first.matchesCapabilities(second)); }
From source file:com.rmn.qa.AutomationRunRequestTest.java
License:Open Source License
@Test // Tests that two run request objects dont match each other due to incorrect os public void testMatchesCapabilitiesBadOs() { String uuid = "testUuid"; String browser = "firefox"; String browserVersion = "20"; Platform os = Platform.LINUX;//w w w . j a v a 2 s. c o m Map<String, Object> map = Maps.newHashMap(); map.put(CapabilityType.BROWSER_NAME, browser); map.put(CapabilityType.VERSION, browserVersion); map.put(CapabilityType.PLATFORM, os); AutomationRunRequest first = new AutomationRunRequest(uuid, null, browser, browserVersion, Platform.WINDOWS); Assert.assertFalse("Capabilities should match", first.matchesCapabilities(map)); }
From source file:com.rmn.qa.AutomationUtils.java
License:Open Source License
/** * Returns true if the platform is from the Windows family * @param platform//from ww w .j av a2 s.co m * @return */ public static boolean isPlatformWindows(Platform platform) { return getUnderlyingFamily(platform) == Platform.WINDOWS; }
From source file:com.rmn.qa.AutomationUtils.java
License:Open Source License
/** * Returns the underlying 'family' of the specified platform * @param platform/*w ww.j a v a 2 s .c o m*/ * @return */ public static Platform getUnderlyingFamily(Platform platform) { if (platform == null) { return null; } if (platform == Platform.UNIX || platform == Platform.WINDOWS || platform == Platform.MAC || platform == Platform.ANY) { return platform; } else { return getUnderlyingFamily(platform.family()); } }