Java 类org.openqa.selenium.Platform 实例源码

项目:crawljax    文件:FirefoxLinuxCrash.java   
private boolean onPosix() {
    Platform current = Platform.getCurrent();
    switch (current) {
        case LINUX:
        case UNIX:
            return true;
        case MAC:
        case ANY:
        case VISTA:
        case WINDOWS:
        case XP:
        case ANDROID:
        default:
            return false;
    }
}
项目:marathonv5    文件:JavaProfile.java   
public String findCommand(String command) {
    if (vmCommand != null) {
        return vmCommand;
    }
    if (javaHome != null) {
        File homeFolder = new File(javaHome);
        if (!homeFolder.exists() || !homeFolder.isDirectory()) {
            throw new WebDriverException(String.format("%s: No such directory", homeFolder));
        }
        File binFolder = new File(javaHome, "bin");
        if (!binFolder.exists() || !binFolder.isDirectory()) {
            throw new WebDriverException(String.format("%s: No bin directory found in home directory", binFolder));
        }
        File java = new File(binFolder, Platform.getCurrent().is(Platform.WINDOWS) ? command + ".exe" : command);
        if (!java.exists() || !java.isFile()) {
            throw new WebDriverException(String.format("%s: No such file", java));
        }
        return java.getAbsolutePath();
    }
    return command;
}
项目:marathonv5    文件:JavaDriverTest.java   
public void failsWhenRequestingNonCurrentPlatform() throws Throwable {
    Platform[] values = Platform.values();
    Platform otherPlatform = null;
    for (Platform platform : values) {
        if (Platform.getCurrent().is(platform)) {
            continue;
        }
        otherPlatform = platform;
        break;
    }
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", otherPlatform);
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
项目:webdriver-supplier    文件:CoreTests.java   
@Test
public void shouldRetrieveBrowserDefaults() {
    final Map<String, String> chromeParameters = new HashMap<>();
    chromeParameters.put(BROWSER_NAME, "chrome");

    final XmlConfig config = new XmlConfig(chromeParameters);
    final Browser chrome = StreamEx.of(browsers)
                                   .findFirst(b -> b.name() == Browser.Name.Chrome)
                                   .orElseThrow(() -> new AssertionError("Unable to retrieve Chrome"));

    assertThat(chrome.isRemote()).isFalse();
    assertThat(chrome.url()).isEqualTo("http://localhost:4444/wd/hub");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getBrowserName)
            .containsExactly("chrome");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getVersion)
            .containsExactly("");
    assertThat(chrome.defaultConfiguration(config))
            .extracting(Capabilities::getPlatform)
            .containsExactly(Platform.getCurrent());
    assertThat(chrome.configuration(config)).isEqualTo(chrome.defaultConfiguration(config));
}
项目:cucumber-framework-java    文件:FileUtils.java   
public static int createNullFile( Path file, long size ) throws IOException, InterruptedException
{
    if( Platform.getCurrent().equals( Platform.LINUX ) || Platform.getCurrent().equals( Platform.MAC ) )
    {
        final String CMD = String.format( "dd if=/dev/zero of=%s count=1024 bs=%d", file, size / 1024 );
        Process process = Runtime.getRuntime().exec( CMD );
        BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
        String processBuffer;
        while ( ( processBuffer = input.readLine() ) != null )
        {
            logger.debug( "create null file: {}", processBuffer );
        }
        input.close();
        return process.waitFor();
    }

    throw new NotImplementedException();
}
项目:cucumber-framework-java    文件:FileUtils.java   
public static int createTextFile( Path file, long size ) throws IOException, InterruptedException
{
    if( Platform.getCurrent().equals( Platform.LINUX ) || Platform.getCurrent().equals( Platform.MAC ) )
    {
        final String CMD = String.format( "dd if=/dev/urandom of=%s count=1024 bs=%d", file, size / 1024 );
        Process process = Runtime.getRuntime().exec( CMD );
        BufferedReader input = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
        String processBuffer;
        while ( ( processBuffer = input.readLine() ) != null )
        {
            logger.debug( "create text file: {}", processBuffer );
        }
        input.close();
        return process.waitFor();

    }

    throw new NotImplementedException();
}
项目:xframium-java    文件:AbstractDriverFactory.java   
/**
 * This method sets the browser capability to the Desired Capabilities
 * @param Object - current device Object value
 * @param DesiredCapabilities
 * @param String - name of the option
 * @return DesiredCapabilities
 */
@SuppressWarnings("unchecked")
protected DesiredCapabilities setCapabilities(Object value, DesiredCapabilities dc, String name) {
    if (value instanceof Boolean)
    {
        dc.setCapability( name, value );
    }

    else if (value instanceof String) 
    {
        dc.setCapability( name, value );
    }

    else if (value instanceof Platform) 
    {
        dc.setCapability( name, value );
    }

    else if (value instanceof Map) 
    {
        dc = BrowserCapabilityManager.instance().getBrowsercapabilityFactory(name)
                .createBrowserOptions(dc, (Map<String,Object>)value);
    }
    return dc;
}
项目:xframium-java    文件:SQLApplicationProvider.java   
private Object getValue( String clazz, String value )
{
    Object rtn = null;

    switch ( clazz )
    {
        case "BOOLEAN":
            rtn = Boolean.parseBoolean( value );
            break;

        case "OBJECT":
            rtn = value;
            break;

        case "STRING":
            rtn = value;
            break;

        case "PLATFORM":
            rtn = ((value != null) ? Platform.valueOf( value.toUpperCase() ) : null );
            break;
    }

    return rtn;
}
项目:webtester2-core    文件:RemoteFactoryTest.java   
@Test
public void capabilitiesAreSetWhenCreatingBrowser() throws MalformedURLException {

    given(configuration.getRemoteBrowserName()).willReturn("firefox");
    given(configuration.getRemoteBrowserVersion()).willReturn("46.0.1");
    given(configuration.getRemoteFirefoxMarionette()).willReturn(true);
    given(configuration.getRemoteHost()).willReturn("localhost");
    given(configuration.getRemotePort()).willReturn(4444);

    cut.createBrowser();

    then(webDriverProducer).should().apply(urlCaptor.capture(), capabilitiesCaptor.capture());

    URL url = urlCaptor.getValue();
    assertThat(url).hasProtocol("http").hasHost("localhost").hasPort(4444).hasPath("/wd/hub");

    DesiredCapabilities capabilities = capabilitiesCaptor.getValue();
    assertThat(capabilities.getCapability(CapabilityType.BROWSER_NAME)).isEqualTo("firefox");
    assertThat(capabilities.getCapability(CapabilityType.VERSION)).isEqualTo("46.0.1");
    assertThat(capabilities.getCapability(CapabilityType.PLATFORM)).isEqualTo(Platform.ANY);
    assertThat(capabilities.getCapability(CapabilityType.HAS_NATIVE_EVENTS)).isEqualTo(false);
    assertThat(capabilities.getCapability(CapabilityType.ACCEPT_SSL_CERTS)).isEqualTo(true);
    assertThat(capabilities.getCapability("marionette")).isEqualTo(true);

}
项目:XPathBuilder    文件:WebDriverFactory.java   
private static DesiredCapabilities setVersionAndPlatform(
        DesiredCapabilities capability, String version, String platform) {
    if (MAC.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.MAC);
    } else if (LINUX.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.LINUX);
    } else if (XP.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.XP);
    } else if (VISTA.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.VISTA);
    } else if (WINDOWS.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.WINDOWS);
    } else if (ANDROID.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.ANDROID);
    } else {
        capability.setPlatform(Platform.ANY);
    }

    if (version != null) {
        capability.setVersion(version);
    }
    return capability;
}
项目:automata    文件:SampleTest.java   
/**
 * Creates a new webdriver instance for your test.
 * @return WebDriver that has been configured to execute the specified platform and browser.
 * @throws MalformedURLException
 */
private WebDriver getDriver() throws MalformedURLException{
    URL server                          = new URL("http://localhost:4444/wd/hub");
    DesiredCapabilities capababilities  = new DesiredCapabilities();

    // Set your OS (platform) here.
    capababilities.setPlatform(Platform.MAC);
    // Set your Browser here.
    capababilities.setBrowserName("chrome");
    // Set your Browser version here. This should be a number.
    capababilities.setVersion("58");
    capababilities.setJavascriptEnabled(true);

    RemoteWebDriver ret = new RemoteWebDriver(server, capababilities);
    ret.navigate().to("https://www.amazon.com/");
    return ret;
}
项目:grid-refactor-remote-server    文件:SnapshotScreenListener.java   
@Override
public void onException(Throwable throwable, WebDriver driver) {
  if (Platform.getCurrent().is(Platform.ANDROID)) {
    // Android Java APIs do not support java.awt
    return;
  }
  String encoded;
  try {
    workAroundD3dBugInVista();

    Rectangle size = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage image = new Robot().createScreenCapture(size);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ImageIO.write(image, "png", outputStream);

    encoded = new Base64Encoder().encode(outputStream.toByteArray());

    session.attachScreenshot(encoded);
  } catch (Throwable e) {
    // Alright. No screen shot. Propogate the original exception
  }
}
项目:AugmentedDriver    文件:TestRunnerConfigTest.java   
@Test
public void testInitializeCapabilitiesFromProperties() throws IOException {
    ClassLoader classLoader = getClass().getClassLoader();
    File origin = new File(classLoader.getResource("converttest.yaml").getFile());
    File dest = folder.newFile();
    FileUtils.copyFile(origin, dest);

    Properties example = new Properties();
    example.setProperty("CAPABILITIES", dest.getCanonicalPath());
    TestRunnerConfig config = TestRunnerConfig.initialize(example);
    Assert.assertEquals("chrome", config.capabilities().getBrowserName());
    Assert.assertEquals("1280x1024", config.capabilities().getCapability("screenResolution"));
    Assert.assertEquals("47.0", config.capabilities().getVersion());
    Assert.assertEquals(Platform.fromString("OS X 10.10"), config.capabilities().getPlatform());

}
项目:hifive-pitalium    文件:FileNameFormatterTest.java   
/**
 * 通常のフォーマットテスト(セレクタ)
 */
@Test
public void testFormat_selector() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
            new IndexDomSelector(SelectorType.TAG_NAME, "body", 1), null, capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_TAG_NAME_body_[1].png"));
}
项目:hifive-pitalium    文件:FileNameFormatterTest.java   
/**
 * 通常のフォーマットテスト(矩形)
 */
@Test
public void testFormat_rectangle() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId", null,
            new RectangleArea(0, 10, 100, 1000), capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_rect_0_10_100_1000.png"));
}
项目:hifive-pitalium    文件:FileNameFormatterTest.java   
/**
 * selendroidのフォーマットテスト
 */
@Test
public void testFormat_selendroid() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.ANDROID);
    capabilities.setBrowserName("");
    capabilities.setCapability("deviceName", "ASUS Pad");
    capabilities.setCapability("platformVersion", "4.0.3");
    capabilities.setCapability("automationName", "Selendroid");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
            new IndexDomSelector(SelectorType.TAG_NAME, "body", 1), null, capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_ANDROID_4.0.3_Selendroid_TAG_NAME_body_[1].png"));
}
项目:hifive-pitalium    文件:FileNameFormatterTest.java   
/**
 * ファイル名に利用できない文字のエスケープテスト
 */
@Test
public void testFormat_escape() throws Exception {
    PtlCapabilities capabilities = new PtlCapabilities(new HashMap<String, Object>());
    capabilities.setPlatform(Platform.WINDOWS);
    capabilities.setBrowserName("firefox");
    capabilities.setVersion("38");

    PersistMetadata metadata = new PersistMetadata("testId", "testClass", "testMethod", "scId",
            new IndexDomSelector(SelectorType.CSS_SELECTOR, "1\\\\2/3:4*5?6\"7<8>9|0", 1), null, capabilities);

    FileNameFormatter formatter = new FileNameFormatter(
            "{platformName}_{platformVersion}_{browserName}_{version}_{screenArea}.png");
    String result = formatter.format(metadata);
    assertThat(result, is("testMethod_scId_WINDOWS_firefox_38_CSS_SELECTOR_1-2-3-4-5-6-7-8-9-0_[1].png"));
}
项目:selenium-reliable-node-plugin    文件:WebProxyHtmlRendererBeta.java   
/**
 * return the platform for the proxy. It should be the same for all slots of the proxy, so checking that.
 * @return Either the platform name, "Unknown", "mixed OS", or "not specified".
 */
public static String getPlatform(RemoteProxy proxy) {
  Platform res = null;
  if (proxy.getTestSlots().size() == 0) {
    return "Unknown";
  } else {
    res = getPlatform(proxy.getTestSlots().get(0));

  }

  for (TestSlot slot : proxy.getTestSlots()) {
    Platform tmp = getPlatform(slot);
    if (tmp != res) {
      return "mixed OS";
    } else {
      res = tmp;
    }
  }
  if (res == null) {
    return "not specified";
  } else {
    return res.toString();
  }
}
项目:atom    文件:WebDriverFactory.java   
private static DesiredCapabilities setVersionAndPlatform(DesiredCapabilities capability, String version, String platform) {
    if (MAC.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.MAC);
    } else if (LINUX.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.LINUX);
    } else if (XP.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.XP);
    } else if (VISTA.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.VISTA);
    } else if (WINDOWS.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.WINDOWS);
    } else if (ANDROID.equalsIgnoreCase(platform)) {
        capability.setPlatform(Platform.ANDROID);
    } else {
        capability.setPlatform(Platform.ANY);
    }

    if (version != null) {
        capability.setVersion(version);
    }
    return capability;
}
项目:selenium-api    文件:PlatformMatcher.java   
@Override
public boolean matches(Object requested, Object provided) {
    Platform requestedPlatform = extractPlatform(requested);

    if (requestedPlatform != null) {
        Platform node = extractPlatform(provided);

        if (node == null) {
            return false;
        }
        if (!node.is(requestedPlatform)) {
            return false;
        }
    } else {
      LOGGER.warning(String.format("Unable to extract requested platform from '%s'.",requested));
    }

    return true;
}
项目:selenium-api    文件:PlatformMatcherTest.java   
@DataProvider
public Object[][] external() {
    return new Object[][]{
            {"win7", Platform.VISTA},
            {"vista", Platform.VISTA},
            {"Vista", Platform.VISTA},
            {"win8_1", Platform.WIN8_1},
            {"XP", Platform.XP},
            {"Win7", Platform.VISTA},
            {"win7", Platform.VISTA},
            {"Windows Server 2012", Platform.WIN8},
            {"windows 8", Platform.WIN8},
            {"win8", Platform.WIN8},
            {"windows 8.1", Platform.WIN8_1},
            {"win8.1", Platform.WIN8_1},
            {null, null},
            {"w8", null},
            {Platform.ANDROID, Platform.ANDROID}
    };
}
项目:senbot    文件:TestEnvironmentTest.java   
@Test
public void testEquals_OS() {
    TestEnvironment left = new TestEnvironment(null, null, Platform.WINDOWS);
    TestEnvironment right = new TestEnvironment(null, null, Platform.WINDOWS);

    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.LINUX);
    assertFalse(left.matches(right));

    right = new TestEnvironment(null, null, Platform.XP);
    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.VISTA);
    assertTrue(left.matches(right));

    right = new TestEnvironment(null, null, Platform.ANY);
    assertTrue(left.matches(right));
}
项目:senbot    文件:TestEnvironmentTest.java   
@Test
public void testCleanupDriver() throws Throwable {
    final WebDriver webDriver = mock(WebDriver.class);
    TestEnvironment env = new TestEnvironment(null, null, Platform.WINDOWS){
        @Override
        public WebDriver getWebDriver(){
            return webDriver;
        }
    };

    assertEquals(webDriver, env.getWebDriver());

    env.cleanupDriver();

    verify(webDriver, times(1)).quit();
    env.cleanupAllDrivers();
}
项目:senbot    文件:TestEnvironmentTest.java   
@Test
public void testIsWebDriverAccessedSince() {
    TestEnvironment env = new TestEnvironment(TestEnvironment.FF, null, Platform.WINDOWS);

    long beforeAccess = System.currentTimeMillis() - 1;
    assertFalse(env.isWebDriverAccessedSince(0));
    assertFalse(env.isWebDriverAccessedSince(beforeAccess));

    env.getWebDriver();
    assertTrue(env.isWebDriverAccessedSince(0));
    assertTrue(env.isWebDriverAccessedSince(beforeAccess));
    assertFalse(env.isWebDriverAccessedSince(System.currentTimeMillis()));

    env.cleanupAllDrivers();

}
项目:chrome-extension-selenium-example    文件:RemoteDriverConfig.java   
/**
 * Here you can add your capabilities you want to use.
 *
 * @see https://code.google.com/p/chromedriver/wiki/CapabilitiesAndSwitches#List_of_recognized_capabilities
 */
protected void buildDesiredCapabilities() {
    DesiredCapabilities capabilities = createDesiredCapabilitiesForChrome();

    // get Platform from environment
    String platformString = System.getenv("PLATFORM");
    if (platformString == null) {
        platformString = Platform.WINDOWS.toString();
    }
    Platform platform = Platform.valueOf(platformString);
    capabilities.setCapability("platform", platform);

    // set browser version
    String versionString = System.getenv("VERSION");
    if (versionString != null) {
        capabilities.setVersion("38");
    }

    // if chrome options are not build yet, we have to handle it
    if (chromeOptions == null) {
        buildChromeOptions();
    }
    capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

    this.desiredCapabilities = capabilities;
}
项目:selendroid    文件:JavaSdk.java   
public static String javaHome() {
  if (javaHome == null) {
    // Sniff JAVA_HOME first
    javaHome = System.getenv("JAVA_HOME");

    // If that's not present, and we're on a Mac...
    if (javaHome == null && Platform.getCurrent() == MAC) {
      try {
        javaHome = ShellCommand.exec(new CommandLine("/usr/libexec/java_home"));
        if (javaHome != null) {
          javaHome = javaHome.replaceAll("\\r|\\n", "");
        }

      } catch (ShellCommandException e) {}
    }
    // Finally, check java.home, though this may point to a JRE.
    if (javaHome == null) {
      javaHome = System.getProperty("java.home");
    }
  }
  return javaHome;
}
项目:jspider    文件:ChromeDesiredCapabilities.java   
public ChromeDesiredCapabilities() {
    super(BrowserType.ANDROID, "", Platform.ANDROID);

    prefs = new HashMap<String, Object>();
    options = new ChromeOptions();
    options.setExperimentalOption("prefs", prefs);
    setCapability(ChromeOptions.CAPABILITY, options);
}
项目:marathonv5    文件:ClassPathHelper.java   
private static String getClassPath(String packageName, String name) {
    name = name.replace('.', '/');
    URL url = ClassPathHelper.class.getResource("/" + name + ".class");
    if (url == null) {
        return null;
    }
    String resource = null;
    try {
        resource = URLDecoder.decode(url.toString(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return null;
    }
    if (resource.startsWith("jar:")) {
        resource = resource.substring(4);
    }
    if (resource.startsWith("file:")) {
        resource = resource.substring(5);
    }
    int index = resource.indexOf('!');
    if (index != -1) {
        resource = resource.substring(0, index);
    } else {
        String packagePath = packageName.replace('.', '/');
        index = resource.indexOf(packagePath);
        if (index != -1) {
            resource = resource.substring(0, index - 1);
        }
    }
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        resource = resource.substring(1);
    }
    return resource.replace('/', File.separatorChar);
}
项目:marathonv5    文件:ClassPathHelper.java   
private static String getClassPath(String packageName, String name) {
    name = name.replace('.', '/');
    URL url = ClassPathHelper.class.getResource("/" + name + ".class");
    if (url == null) {
        return null;
    }
    String resource = null;
    try {
        resource = URLDecoder.decode(url.toString(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return null;
    }
    if (resource.startsWith("jar:")) {
        resource = resource.substring(4);
    }
    if (resource.startsWith("file:")) {
        resource = resource.substring(5);
    }
    int index = resource.indexOf('!');
    if (index != -1) {
        resource = resource.substring(0, index);
    } else {
        String packagePath = packageName.replace('.', '/');
        index = resource.indexOf(packagePath);
        if (index != -1) {
            resource = resource.substring(0, index - 1);
        }
    }
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
        resource = resource.substring(1);
    }
    return resource.replace('/', File.separatorChar);
}
项目:marathonv5    文件:JavaProfile.java   
private String findJavaWSBinary() {
    if (vmCommand != null) {
        return vmCommand;
    }
    if (Platform.getCurrent().is(Platform.MAC)) {
        return "javaws";
    }
    return findCommand("javaws");
}
项目:marathonv5    文件:JListXTest.java   
public void listMultipleSelectWithControl() throws Throwable {
    driver = new JavaDriver();
    WebElement listItem;
    listItem = driver.findElement(By.cssSelector("#list-1::nth-item(6)"));
    WebElement listItem2 = driver.findElement(By.cssSelector("#list-1::nth-item(3)"));
    WebElement listItem3 = driver.findElement(By.cssSelector("#list-1::nth-item(4)"));
    Keys command = Platform.getCurrent().is(Platform.MAC) ? Keys.COMMAND : Keys.CONTROL;
    new Actions(driver).click(listItem).sendKeys(command).click(listItem2).click(listItem3).sendKeys(command).perform();
    ArrayList<Integer> al = new ArrayList<Integer>();
    int[] selectedIndices = new int[] { 2, 3, 5 };
    for (int i : selectedIndices) {
        al.add(i);
    }
    assertEquals(al.toString(), driver.findElement(By.cssSelector("#list-1")).getAttribute("selectedIndices"));
}
项目: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) {
    }
}
项目: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) {
    }
}
项目: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"));
}
项目: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"));
}
项目:marathonv5    文件:LaunchJavaCommandLineTest.java   
@BeforeClass public void createDriver() {
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE);
    File f = findFile();
    profile.addClassPath(f);
    profile.setMainClass("com.sun.swingset3.SwingSet3");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
项目:marathonv5    文件:LaunchCommandLineTest.java   
@BeforeClass public void createDriver() {
    JavaProfile profile = new JavaProfile(LaunchMode.COMMAND_LINE);
    File f = findFile();
    profile.setCommand(f.getAbsolutePath());
    profile.addApplicationArguments("Argument1");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}
项目:marathonv5    文件:LaunchJavaCommandLineTest.java   
@BeforeMethod public void createDriver() {
    System.setProperty(Constants.PROP_PROJECT_FRAMEWORK, Constants.FRAMEWORK_SWING);
    JavaProfile profile = new JavaProfile(LaunchMode.JAVA_COMMAND_LINE);
    File f = findFile();
    profile.addClassPath(f);
    profile.setRecordingPort(startRecordingServer());
    profile.setMainClass("com.sun.swingset3.SwingSet3");
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.5", Platform.ANY);
    driver = new JavaDriver(profile, caps, caps);
}