Example usage for org.openqa.selenium.support ByIdOrName ByIdOrName

List of usage examples for org.openqa.selenium.support ByIdOrName ByIdOrName

Introduction

In this page you can find the example usage for org.openqa.selenium.support ByIdOrName ByIdOrName.

Prototype

public ByIdOrName(String idOrName) 

Source Link

Usage

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the header.//from  w  w  w .j av a 2  s .  c  o m
 * 
 * @param uri
 *          the uri
 * @return the header
 */
public WebElement getHeader(final String uri) {
    final String pageId = Idify.uriId(uri);
    final String headerId = "gwt-debug-HeaderWidget-Chat-" + pageId;
    return findElement(new ByIdOrName(headerId));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the item menu.//  w  w  w  . j a  va  2s .co m
 * 
 * @param groupId
 *          the group id
 * @param jid
 *          the jid
 * @return the item menu
 */
public WebElement getItemMenu(final String groupId, final String jid) {
    final String id = Idify.id("RosterItemWidget", groupId, Idify.uriId(jid), "roster-menu");
    return findElement(new ByIdOrName("gwt-debug-" + id));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the list.//from   ww w.  ja  v a 2  s.  co  m
 * 
 * @param uri
 *          the uri
 * @return the list
 */
public WebElement getList(final String uri) {
    final String pageId = Idify.uriId(uri);
    final String id = "gwt-debug-ChatWidget-list-Chat-" + pageId;
    return findElement(new ByIdOrName(id));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the page.//from  w w  w  .j av a 2s .c  o m
 * 
 * @param uri
 *          the uri
 * @return the page
 */
public WebElement getPage(final String uri) {
    final String pageId = Idify.uriId(uri);
    final String headerId = "gwt-debug-ChatWidget-Chat-" + pageId;
    return findElement(new ByIdOrName(headerId));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the roster item.//  www . j  a  v a2s.co m
 * 
 * @param groupId
 *          the group id
 * @param jid
 *          the jid
 * @return the roster item
 */
public WebElement getRosterItem(final String groupId, final String jid) {
    final String id = Idify.id("RosterItemWidget", groupId, Idify.uriId(jid));
    return findElement(new ByIdOrName("gwt-debug-" + id));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the send.//from  w ww.  j av a2s.c  o m
 * 
 * @param uri
 *          the uri
 * @return the send
 */
public WebElement getSend(final String uri) {
    final String pageId = Idify.uriId(uri);
    final String id = "gwt-debug-ChatWidget-send-Chat-" + pageId;
    return findElement(new ByIdOrName(id));
}

From source file:cc.kune.selenium.chat.ChatPageObject.java

License:GNU Affero Public License

/**
 * Gets the talk box.//w w w . j  a  v  a2 s.c om
 * 
 * @param uri
 *          the uri
 * @return the talk box
 */
public WebElement getTalkBox(final String uri) {
    final String pageId = Idify.uriId(uri);
    final String id = "gwt-debug-ChatWidget-talkBox-Chat-" + pageId;
    return findElement(new ByIdOrName(id));
}

From source file:cc.kune.selenium.PageObject.java

License:GNU Affero Public License

/**
 * Wait for id./*from  www.j  a v a  2s .  c o m*/
 * 
 * @param id
 *          the id
 */
protected void waitForId(final String id) {
    // LOG.info("WAIT FOR: " + id);
    waitFor(id, new Runnable() {
        @Override
        public void run() {
            Assert.assertTrue(getWebDriver().findElement(new ByIdOrName(id)).isDisplayed());
        }
    });
}

From source file:com.mengge.pagefactory.DefaultElementByBuilder.java

License:Apache License

@Override
public By buildBy() {
    assertValidAnnotations();/*from ww w  .  j a  va  2s . c om*/

    By defaultBy = buildDefaultBy();
    By mobileNativeBy = buildMobileNativeBy();

    String idOrName = ((Field) annotatedElementContainer.getAnnotated()).getName();

    if (defaultBy == null && mobileNativeBy == null) {
        defaultBy = new ByIdOrName(((Field) annotatedElementContainer.getAnnotated()).getName());
        mobileNativeBy = new By.ById(idOrName);
        return returnMappedBy(defaultBy, mobileNativeBy);
    }

    if (defaultBy == null) {
        defaultBy = new ByIdOrName(((Field) annotatedElementContainer.getAnnotated()).getName());
        return returnMappedBy(defaultBy, mobileNativeBy);
    }

    if (mobileNativeBy == null) {
        mobileNativeBy = defaultBy;
        return returnMappedBy(defaultBy, mobileNativeBy);
    }

    return returnMappedBy(defaultBy, mobileNativeBy);
}

From source file:com.raja.anucarita.SeCustomUtils.java

License:Open Source License

public static WebElement elementReturn(WebDriver driver, String locator) throws Exception {
    byMethod = locator.split("=", 2)[0];
    actualLocator = locator.split("=", 2)[1];

    if (byMethod.equalsIgnoreCase("css")) {
        element = driver.findElement(By.cssSelector(actualLocator));
    } else if (byMethod.equalsIgnoreCase("jQuery")) {
        final String LocatorTwo = actualLocator;
        String Timeout = values.getProperty("timeout");
        try {/*  w ww  .  jav  a 2s.  c o m*/
            wait = new WebDriverWait(driver, Integer.parseInt(Timeout));
            wait.until(new ExpectedCondition<Boolean>() {
                public Boolean apply(WebDriver driver) {
                    Result = false;
                    try {
                        element = findElementByjQuery(driver, LocatorTwo);
                        if (element instanceof WebElement) {
                            Result = true;
                        } else {
                            Result = false;
                        }
                    } catch (Exception e) {
                    }
                    return Result;
                }
            });
        } catch (Exception e) {
        }
        element = findElementByjQuery(driver, actualLocator);
    } else if (byMethod.equalsIgnoreCase("linkText")) {
        element = driver.findElement(By.linkText(actualLocator));
    } else if (byMethod.equalsIgnoreCase("id")) {
        element = driver.findElement(By.id(actualLocator));
    } else if (byMethod.equalsIgnoreCase("name")) {
        element = driver.findElement(By.name(actualLocator));
    } else if (byMethod.equalsIgnoreCase("ByIDorName")) {
        driver.findElement(new ByIdOrName(actualLocator));
    } else if (byMethod.equalsIgnoreCase("partialLinkText")) {
        element = driver.findElement(By.partialLinkText(actualLocator));
    } else if (byMethod.equalsIgnoreCase("xpath")) {
        element = driver.findElement(By.xpath(actualLocator));
    } else {
    }
    if (element instanceof WebElement) {
        return element;
    } else {
        element = null;
    }
    return null;
}