Example usage for org.openqa.selenium.remote RemoteWebElement setId

List of usage examples for org.openqa.selenium.remote RemoteWebElement setId

Introduction

In this page you can find the example usage for org.openqa.selenium.remote RemoteWebElement setId.

Prototype

public void setId(String id) 

Source Link

Usage

From source file:com.vaadin.testbench.TestBenchElementTest.java

@Test
public void elementsEquals() {
    RemoteWebElement webElement = new RemoteWebElement();
    webElement.setId("remote1");
    TestBenchElement element = TestBenchElement.wrapElement(webElement, null);
    TestBenchElement element2 = TestBenchElement.wrapElement(webElement, null);

    assertTrue(webElement.equals(webElement));
    assertTrue(element.equals(element));
    assertTrue(webElement.equals(element));
    assertTrue(element.equals(webElement));

    assertTrue(element.equals(element2));
    assertTrue(element2.equals(element));

}

From source file:com.vaadin.testbench.TestBenchElementTest.java

@Test
public void elementsHashCode() {
    RemoteWebElement webElement = new RemoteWebElement();
    webElement.setId("remote1");
    TestBenchElement element = TestBenchElement.wrapElement(webElement, null);

    HashSet<WebElement> elements = new HashSet<WebElement>();
    elements.add(webElement);//from ww  w  . jav a 2s  .c  o  m
    elements.add(element);
    Assert.assertEquals(1, elements.size());

}

From source file:org.uiautomation.ios.client.uiamodels.impl.RemoteIOSObject.java

License:Apache License

/**
 * Uses reflection to instanciate a remote object implementing the correct interface.
 *
 * @return the object. If the object is UIAElementNil, return null for a simple object, an empty
 *         list for a UIAElementArray.//from   w ww . j a  v a2  s .  co  m
 */
public static WebElement createObject(RemoteWebDriver driver, Map<String, Object> ro) {
    String ref = ro.get("ELEMENT").toString();

    String type = (String) ro.get("type");
    if (type != null) {
        String remoteObjectName = "org.uiautomation.ios.client.uiamodels.impl.Remote" + type;

        if ("UIAElementNil".equals(type)) {
            return null;
        }

        boolean isArray = false; // uiObject.has("length");

        Object[] args = null;
        Class<?>[] argsClass = null;

        if (isArray) {
            // args = new Object[] {driver, ref, uiObject.getInt("length")};
            // argsClass = new Class[] {RemoteIOSDriver.class, String.class,
            // Integer.class};
        } else {
            args = new Object[] { driver, ref };
            argsClass = new Class[] { RemoteWebDriver.class, String.class };
        }
        try {
            Class<?> clazz = Class.forName(remoteObjectName);
            Constructor<?> c = clazz.getConstructor(argsClass);
            Object o = c.newInstance(args);
            RemoteWebElement element = (RemoteWebElement) o;
            element.setFileDetector(driver.getFileDetector());
            element.setParent(driver);
            element.setId(ref);
            return (RemoteIOSObject) o;
        } catch (Exception e) {
            throw new WebDriverException("error casting", e);
        }
    } else {
        RemoteWebElement element = new RemoteWebElement();
        element.setFileDetector(driver.getFileDetector());
        element.setId(ref);
        element.setParent(driver);
        return element;
    }

}