Example usage for org.openqa.selenium By name

List of usage examples for org.openqa.selenium By name

Introduction

In this page you can find the example usage for org.openqa.selenium By name.

Prototype

public static By name(String name) 

Source Link

Usage

From source file:com.ecofactor.qa.automation.newapp.page.impl.LoginPageImpl.java

License:Open Source License

/**
 * verifies the default focus for the login screen is with username.
 * @return true, if is default focus with username
 *///w w w . ja va2s .com
@Override
public boolean isDefaultFocusWithUsername() {

    WaitUtil.mediumWait();
    isDisplayed(getDriver(), By.name(USERNAME), MEDIUM_TIMEOUT);
    String value = getElement(getDriver(), By.name(USERNAME), TINY_TIMEOUT).getAttribute(AUTOFOCUS);
    LogUtil.setLogString("Autofocus:" + value, true);
    return value.equalsIgnoreCase(TRUE);
}

From source file:com.ecofactor.qa.automation.newapp.page.impl.LoginPageImpl.java

License:Open Source License

/**
 * validates the check box is clicked or not of remember Mail.
 * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickRememberEvent(java.lang.String,
 *      java.lang.String)/*  www  .  j a v  a  2 s.c om*/
 */
@Override
public void clickRememberEvent() {

    WebElement checkElement = getElement(getDriver(), By.name(CHECKBOX_NAME), MEDIUM_TIMEOUT);
    if (!checkElement.isSelected()) {

        LogUtil.setLogString("Click Remember Mail", true);
        getAction().click(checkElement);
        WaitUtil.tinyWait();
        getAction().rejectAlert();
    } else if ((checkElement.getAttribute("checked")) != null) {

        LogUtil.setLogString("UnCheck if Remember Mail Clicked already!", true);
        getAction().click(checkElement);
        WaitUtil.tinyWait();
        /* getAction().rejectAlert(); */
        if (!checkElement.isSelected()) {

            LogUtil.setLogString("Click Remember Mail", true);
            getAction().click(checkElement);
            WaitUtil.tinyWait();
            getAction().rejectAlert();
        }
    }
}

From source file:com.ecofactor.qa.automation.platform.action.impl.IOSUIAction.java

License:Open Source License

/**
 * Accept alert./*from  w  ww  . java  2  s .co  m*/
 * @see com.ecofactor.qa.automation.mobile.action.impl.AbstractMobileUIAction#acceptAlert()
 */
@Override
public void acceptAlert() {

    driverOps.switchToNative();
    setLogString("Click OK button", true);
    driverOps.getDeviceDriver().findElement(By.name("OK")).click();
    mediumWait();
}

From source file:com.ecofactor.qa.automation.qtc.page.QTCLoginImpl.java

License:Open Source License

/**
 * Enter login.//  ww  w . j  ava2 s .c om
 * @param userName the user name
 * @param password the password
 * @see com.ecofactor.qa.automation.qtc.page.QTCLogin#enterLogin(java.lang.String,
 *      java.lang.String)
 */
@Override
public void enterLogin(String userName, String password) {

    largeWait();

    //boolean qtcPage = isDisplayedByClassName(DriverConfig.getDriver(), loginConfig.get(USER_NAME), SHORT_TIMEOUT);
    //assertTrue(qtcPage, "Page is not loading");
    WebElement userField = DriverConfig.getDriver().findElement(By.name(loginConfig.get(USER_NAME)));
    WebElement passwordField = DriverConfig.getDriver().findElement(By.name(loginConfig.get(PASSWORD)));
    assertNotNull(userField);
    assertNotNull(passwordField);

    DriverConfig.setLogString("Enter username and password", true);
    userField.sendKeys(userName);
    passwordField.sendKeys(password);

}

From source file:com.ecofactor.qa.automation.qtc.page.TaskPageImpl.java

License:Open Source License

/**
 * Select action./*w  w w .  j a  v  a2  s.com*/
 * @param actionName the action name
 * @see com.ecofactor.qa.automation.qtc.page.TaskPage#selectAction(java.lang.String)
 */
public void selectAction(String actionName) {

    DriverConfig.setLogString("Select Action :" + actionName, true);

    tinyWait();
    Select selectAction = new Select(DriverConfig.getDriver().findElement(By.name(taskConfig.get(ACTION))));
    selectAction.selectByVisibleText(actionName);
}

From source file:com.ecofactor.qa.automation.qtc.page.TaskPageImpl.java

License:Open Source License

/**
 * Select algo./*from ww w.  j  av  a 2s.c o  m*/
 * @param algoName the algo name
 * @see com.ecofactor.qa.automation.qtc.page.TaskPage#selectAlgo(java.lang.String)
 */
public void selectAlgo(String algoName) {

    DriverConfig.setLogString("Select algoname : " + algoName, true);

    Select selectAlgo = new Select(DriverConfig.getDriver().findElement(By.name(taskConfig.get(ALGO))));
    selectAlgo.selectByVisibleText(algoName);
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Select the option by text according to name.
 * @param formElement the form element/*w w w  . j a v  a2s  .c o m*/
 * @param selectId the select id
 * @param selectText the select text
 */
public static void selectOptionByTextbyName(final WebElement formElement, final String selectId,
        final String selectText) {

    logger.info("Select id:" + selectId + " ; selectText" + selectText);
    Select select = new Select(formElement.findElement(By.name(selectId)));
    select.selectByVisibleText(selectText);
}

From source file:com.elastica.webelements.HtmlElement.java

License:Apache License

private By getLocatorBy(final String locator, final LocatorType locatorType) {
    switch (locatorType) {

    case ID://from   w  w w  .  jav a 2  s.c o  m
        return By.id(locator);

    case NAME:
        return By.name(locator);

    case CLASS_NAME:
        return By.className(locator);

    case LINK_TEXT:
        return By.linkText(locator);

    case PARTIAL_LINK_TEXT:
        return By.partialLinkText(locator);

    case CSS_SELECTOR:
        return By.cssSelector(locator);

    case TAG_NAME:
        return By.tagName(locator);

    default:
        return By.xpath(locator);
    }
}

From source file:com.epam.jdi.uitests.mobile.appium.driver.WebDriverByUtils.java

License:Open Source License

public static By getByFromString(String stringLocator) {
    if (stringLocator == null || stringLocator.equals(""))
        throw new RuntimeException("Can't get By locator from string empty or null string");
    String[] split = stringLocator.split("(^=)*=.*");
    if (split.length == 1)
        return By.cssSelector(split[0]);
    switch (split[0]) {
    case "css":
        return By.cssSelector(split[1]);
    case "xpath":
        return By.xpath(split[1]);
    case "class":
        return By.className(split[1]);
    case "name":
        return By.name(split[1]);
    case "id":
        return By.id(split[1]);
    case "tag":
        return By.tagName(split[1]);
    case "link":
        return By.partialLinkText(split[1]);
    default:/*from w w w.  ja  v  a  2s . co m*/
        throw new RuntimeException(String.format(
                "Can't get By locator from string: %s. Bad suffix: %s. (available: css, xpath, class, id, name, link, tag)",
                stringLocator, split[0]));
    }
}

From source file:com.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.AppiumAnnotationsUtil.java

License:Open Source License

public static By getFrame(Frame frame) {
    if (frame == null)
        return null;
    if (!"".equals(frame.id()))
        return By.id(frame.id());
    if (!"".equals(frame.className()))
        return By.className(frame.className());
    if (!"".equals(frame.xpath()))
        return By.xpath(frame.xpath());
    if (!"".equals(frame.css()))
        return By.cssSelector(frame.css());
    if (!"".equals(frame.linkText()))
        return By.linkText(frame.linkText());
    if (!"".equals(frame.name()))
        return By.name(frame.name());
    if (!"".equals(frame.partialLinkText()))
        return By.partialLinkText(frame.partialLinkText());
    if (!"".equals(frame.tagName()))
        return By.tagName(frame.tagName());
    return null;// w  w  w . j ava  2s  . co  m
}