org.openqa.selenium.Platform#getCurrent ( )源码实例Demo

下面列出了org.openqa.selenium.Platform#getCurrent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: selenium   文件: FirefoxBinary.java
public FirefoxBinary() {
  Executable systemBinary = locateFirefoxBinaryFromSystemProperty();
  if (systemBinary != null) {
    executable = systemBinary;
    return;
  }

  Executable platformBinary = locateFirefoxBinariesFromPlatform().findFirst().orElse(null);
  if (platformBinary != null) {
    executable = platformBinary;
    return;
  }

  throw new WebDriverException("Cannot find firefox binary in PATH. " +
                               "Make sure firefox is installed. OS appears to be: " + Platform.getCurrent());
}
 
源代码2 项目: selenium   文件: HttpClientTestBase.java
@Test
public void shouldIncludeAUserAgentHeader() throws Exception {
  HttpResponse response = executeWithinServer(
      new HttpRequest(GET, "/foo"),
      new HttpServlet() {
        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
          try (Writer writer = resp.getWriter()) {
            writer.write(req.getHeader("user-agent"));
          }
        }
      });


  String label = new BuildInfo().getReleaseLabel();
  Platform platform = Platform.getCurrent();
  Platform family = platform.family() == null ? platform : platform.family();

  assertThat(string(response)).isEqualTo(String.format(
      "selenium/%s (java %s)",
      label,
      family.toString().toLowerCase()));
}
 
源代码3 项目: marathonv5   文件: JavaDriverTest.java
public void failsWhenRequestingANonJavaDriver() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("xjava", "1.0", Platform.getCurrent());
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
 
源代码4 项目: marathonv5   文件: JavaDriverTest.java
public void failsWhenRequestingUnsupportedCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setCapability("rotatable", true);
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
 
源代码5 项目: marathonv5   文件: JavaDriverTest.java
public void succeedsWhenRequestingNativeEventsCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setCapability("nativeEvents", true);
    driver = new JavaDriver(caps, caps);
    Capabilities capabilities = ((RemoteWebDriver) driver).getCapabilities();
    AssertJUnit.assertTrue(capabilities.is("nativeEvents"));
}
 
源代码6 项目: marathonv5   文件: JavaDriverTest.java
public void succeedsWhenRequestingNonNativeEventsCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setCapability("nativeEvents", false);
    driver = new JavaDriver(caps, caps);
    Capabilities capabilities = ((RemoteWebDriver) driver).getCapabilities();
    AssertJUnit.assertTrue(!capabilities.is("nativeEvents"));
}
 
public void launchDriver(String browser) throws UnCaughtException {
    RunContext context = new RunContext();
    context.BrowserName = browser;
    context.Browser = Browser.fromString(browser);
    context.Platform = Platform.getCurrent();
    context.BrowserVersion = "default";
    launchDriver(context);
}
 
源代码8 项目: selenium   文件: CommandLine.java
/**
 * @return The platform specific env property name which contains the library path.
 */
public static String getLibraryPathPropertyName() {
  Platform current = Platform.getCurrent();

  if (current.is(WINDOWS)) {
    return "PATH";

  } else if (current.is(MAC)) {
    return "DYLD_LIBRARY_PATH";

  } else {
    return "LD_LIBRARY_PATH";
  }
}
 
源代码9 项目: selenium   文件: InternetExplorerDriver.java
protected void assertOnWindows() {
  Platform current = Platform.getCurrent();
  if (!current.is(Platform.WINDOWS)) {
    throw new WebDriverException(
        String.format(
            "You appear to be running %s. The IE driver only runs on Windows.", current));
  }
}
 
源代码10 项目: selenium   文件: DriverFactoryTest.java
@Test
public void testShouldReturnMatchIfOneFieldMatchesAndOnlyOneDriverIsRegistered() {
  Capabilities template = new DesiredCapabilities("foo", "1.0", Platform.getCurrent());
  DriverProvider provider = mockDriverProviderFor(template);

  factory.registerDriverProvider(provider);

  Capabilities example = new ImmutableCapabilities(BROWSER_NAME, template.getBrowserName());
  assertEquals(provider, factory.getProviderMatching(example));
}
 
源代码11 项目: marathonv5   文件: JavaDriverTest.java
public void supportsJavascriptEnabledCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setJavascriptEnabled(true);
    driver = new JavaDriver(caps, caps);
}
 
public String getPlatformName() {
    Platform platform = null;
    String mode = Control.exe.getExecSettings().getRunSettings().getExecutionMode();
    boolean isLocal = mode.equalsIgnoreCase("Local");
    if (runContext.Platform.equals(Platform.ANY) || runContext.Platform.equals(Platform.getCurrent())) {
        Capabilities cap;
        if (driver instanceof ExtendedHtmlUnitDriver) {
            cap = ((ExtendedHtmlUnitDriver) driver).getCapabilities();
        } else if (driver instanceof MobileDriver) {
            cap = ((RemoteWebDriver) driver).getCapabilities();
            Object platf = cap.getCapability("platformName");
            if (platf != null && !platf.toString().isEmpty()) {
                return platf.toString();
            } else {
                return (driver instanceof AndroidDriver) ? "Android" : "IOS";
            }
        } else if (driver instanceof EmptyDriver) {
            return Platform.getCurrent().name();
        } else {
            cap = ((RemoteWebDriver) driver).getCapabilities();
        }
        platform = cap.getPlatform();
        if (isLocal) {
            platform = Platform.getCurrent();
        }
        if (platform.name().equals(Platform.VISTA.name()) || platform.name().equals(Platform.XP.name())
                || platform.name().equals(Platform.WINDOWS.name()) || platform.name().equals(Platform.WIN8.name())) {
            switch (platform.getMajorVersion() + "." + platform.getMinorVersion()) {
                case "5.1":
                    return "XP";
                case "6.0":
                    return "VISTA";
                case "6.1":
                    return "WIN7";
                case "6.2":
                    return "WIN8";
                case "6.3":
                    return "WIN8.1";
                default:
                    return platform.name();
            }
        } else {
            return platform.toString();
        }
    } else if (runContext.PlatformValue.equals("WINDOWS")) {
        return "WIN";
    } else {
        if (isLocal) {
            platform = Platform.getCurrent();
            return platform.toString();
        }
        return runContext.PlatformValue;
    }
}
 
源代码13 项目: selenium   文件: TestUtilities.java
public static Platform getEffectivePlatform() {
  return Platform.getCurrent();
}
 
源代码14 项目: selenium   文件: DriverFactoryTest.java
@Before
public void setUp() {
  factory = new DefaultDriverFactory(Platform.getCurrent());
}