List of usage examples for org.openqa.selenium Platform getCurrent
public static Platform getCurrent()
From source file:RunIpadAcceptanceTests.java
License:Apache License
@BeforeClass public static void setupSquashWebsiteUrl() { Platform current = Platform.getCurrent(); Assert.assertTrue("Safari can be used only on MAC and Windows platforms", Platform.MAC.is(current) || Platform.WINDOWS.is(current)); Properties p = new Properties(System.getProperties()); p.setProperty("SquashWebsiteBaseUrl", "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-16.html"); // This will be read before each scenario to set up the webdriver p.setProperty("WebDriverType", "Ipad"); p.setProperty("WebDriverJavascriptEnabled", "true"); System.setProperties(p);/* w w w. jav a 2s .c om*/ }
From source file:ExperimentRunner.java
License:Apache License
private static boolean isSupportedPlatform() { Platform current = Platform.getCurrent(); return Platform.MAC.is(current) || Platform.WINDOWS.is(current); }
From source file:RunFirefoxAcceptanceTests.java
License:Apache License
@BeforeClass public static void setupSquashWebsiteUrl() { Platform current = Platform.getCurrent(); Assert.assertTrue("Safari can be used only on MAC and Windows platforms", Platform.MAC.is(current) || Platform.WINDOWS.is(current)); Properties p = new Properties(System.getProperties()); p.setProperty("SquashWebsiteBaseUrl", "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-11.html"); // This will be read before each scenario to set up the webdriver p.setProperty("WebDriverType", "Firefox"); p.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox-bin"); p.setProperty("WebDriverJavascriptEnabled", "true"); System.setProperties(p);/*from w ww . j a v a 2 s . c o m*/ }
From source file:RunSafariAcceptanceTests.java
License:Apache License
@BeforeClass public static void setupSquashWebsiteUrl() { Platform current = Platform.getCurrent(); Assert.assertTrue("Safari can be used only on MAC and Windows platforms", Platform.MAC.is(current) || Platform.WINDOWS.is(current)); Properties p = new Properties(System.getProperties()); p.setProperty("SquashWebsiteBaseUrl", "http://squashwebsite.s3-website-eu-west-1.amazonaws.com/?selectedDate=2016-01-11.html"); // This will be read before each scenario to set up the webdriver p.setProperty("WebDriverType", "Safari"); p.setProperty("WebDriverJavascriptEnabled", "true"); System.setProperties(p);//from ww w. ja v a 2 s . c om }
From source file:com.atlassian.selenium.browsers.firefox.DisplayAwareFirefoxChromeLauncher.java
License:Apache License
protected CommandLine prepareCommand(String... commands) { CommandLine command = new CommandLine(commands); command.setEnvironmentVariable("MOZ_NO_REMOTE", "1"); // don't set the library path on Snow Leopard Platform platform = Platform.getCurrent(); if (!platform.is(Platform.MAC) || ((platform.is(Platform.MAC)) && platform.getMajorVersion() <= 10 && platform.getMinorVersion() <= 5)) { command.setDynamicLibraryPath(browserInstallation.libraryPath()); }// w ww. ja v a 2s .c o m if (System.getProperty("DISPLAY") != null) { command.setEnvironmentVariable("DISPLAY", System.getProperty("DISPLAY")); } return command; }
From source file:com.github.mike10004.seleniumhelp.UnitTests.java
License:Apache License
/** * Locates the firefox binary by platform. * <p>/* w w w .j a v a 2 s . co m*/ * Copied from Selenium's FirefoxBinary.java. See license above. */ @SuppressWarnings("deprecation") private static Stream<Executable> locateFirefoxBinariesFromPlatform() { ImmutableList.Builder<Executable> executables = new ImmutableList.Builder<>(); Platform current = Platform.getCurrent(); if (current.is(WINDOWS)) { executables.addAll(Stream .of(getPathsInProgramFiles("Mozilla Firefox\\firefox.exe"), getPathsInProgramFiles("Firefox Developer Edition\\firefox.exe"), getPathsInProgramFiles("Nightly\\firefox.exe")) .flatMap(List::stream).map(File::new).filter(File::exists).map(Executable::new) .collect(toList())); } else if (current.is(MAC)) { // system File binary = new File("/Applications/Firefox.app/Contents/MacOS/firefox-bin"); if (binary.exists()) { executables.add(new Executable(binary)); } // user home binary = new File(System.getProperty("user.home") + binary.getAbsolutePath()); if (binary.exists()) { executables.add(new Executable(binary)); } } else if (current.is(UNIX)) { String systemFirefoxBin = new ExecutableFinder().find("firefox-bin"); if (systemFirefoxBin != null) { executables.add(new Executable(new File(systemFirefoxBin))); } } String systemFirefox = new ExecutableFinder().find("firefox"); if (systemFirefox != null) { Path firefoxPath = new File(systemFirefox).toPath(); if (Files.isSymbolicLink(firefoxPath)) { try { Path realPath = firefoxPath.toRealPath(); File attempt1 = realPath.getParent().resolve("firefox").toFile(); if (attempt1.exists()) { executables.add(new Executable(attempt1)); } else { File attempt2 = realPath.getParent().resolve("firefox-bin").toFile(); if (attempt2.exists()) { executables.add(new Executable(attempt2)); } } } catch (IOException e) { // ignore this path } } else { executables.add(new Executable(new File(systemFirefox))); } } return executables.build().stream(); }
From source file:com.jaliansystems.customiSE.example.TestCalc.java
License:Apache License
private String findJavaExe() { String exe = "java"; if (Platform.getCurrent().is(Platform.WINDOWS)) exe = "java.exe"; File binDir = new File(System.getProperty("java.home"), "bin"); if (binDir.isDirectory()) { File exeFile = new File(binDir, exe); if (exeFile.exists()) try { return exeFile.getCanonicalPath(); } catch (IOException e) { }/*from w w w . ja v a 2 s .c o m*/ } return null; }
From source file:com.mengge.service.local.AppiumServiceBuilder.java
License:Apache License
private void setUpNPMScript() { if (npmScript != null) { return;/*w w w . j av a2 s . c o m*/ } if (!Platform.getCurrent().is(Platform.WINDOWS)) { npmScript = Scripts.GET_PATH_TO_DEFAULT_NODE_UNIX.getScriptFile(); } }
From source file:com.mengge.service.local.AppiumServiceBuilder.java
License:Apache License
private File findNodeInCurrentFileSystem() { setUpNPMScript();//from w w w. j av a 2 s . c o m String instancePath; CommandLine commandLine; try { if (Platform.getCurrent().is(Platform.WINDOWS)) { commandLine = new CommandLine(CMD_EXE, "/C", "npm root -g"); } else { commandLine = new CommandLine(BASH, "-l", npmScript.getAbsolutePath()); } commandLine.execute(); } catch (Throwable e) { throw new RuntimeException(e); } instancePath = (commandLine.getStdOut()).trim(); try { File defaultAppiumNode; if (StringUtils.isBlank(instancePath) || !(defaultAppiumNode = new File(instancePath + File.separator + APPIUM_FOLDER)).exists()) { String errorOutput = commandLine.getStdOut(); throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException(errorOutput)); } //appium?v1.5 File result; if ((result = new File(defaultAppiumNode, APPIUM_NODE_MASK)).exists()) { return result; } throw new InvalidServerInstanceException(ERROR_NODE_NOT_FOUND, new IOException( "?" + APPIUM_NODE_MASK + "," + defaultAppiumNode + "")); } finally { commandLine.destroy(); } }
From source file:com.mengge.service.local.AppiumServiceBuilder.java
License:Apache License
@Override protected File findDefaultExecutable() { String nodeJSExec = System.getProperty(NODE_PATH); if (StringUtils.isBlank(nodeJSExec)) { nodeJSExec = System.getenv(NODE_PATH); }/* w ww . ja v a2 s .co m*/ if (!StringUtils.isBlank(nodeJSExec)) { File result = new File(nodeJSExec); if (result.exists()) { return result; } } CommandLine commandLine; setUpGetNodeJSExecutableScript(); try { if (Platform.getCurrent().is(Platform.WINDOWS)) { commandLine = new CommandLine(NODE + ".exe", getNodeJSExecutable.getAbsolutePath()); } else { commandLine = new CommandLine(NODE, getNodeJSExecutable.getAbsolutePath()); } commandLine.execute(); } catch (Throwable t) { throw new InvalidNodeJSInstance("Node.js!", t); } String filePath = (commandLine.getStdOut()).trim(); try { if (StringUtils.isBlank(filePath) || !new File(filePath).exists()) { String errorOutput = commandLine.getStdOut(); String errorMessage = "Can't get a path to the default Node.js instance"; throw new InvalidNodeJSInstance(errorMessage, new IOException(errorOutput)); } return new File(filePath); } finally { commandLine.destroy(); } }