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.easytox.automation.steps.LabClientImpl.java

private void authorization() {
    driver.navigate().to(LOGIN_PAGE_URL);

    WebElement element = driver.findElement(By.name(FIND_USERNAME));
    element.clear();//from   w  ww  .  jav  a 2  s  .co  m
    element.sendKeys(LOGIN);

    WebElement el = driver.findElement(By.name(FIND_LOGIN));
    el.clear();
    el.sendKeys(PASSWORD);

    driver.findElement(By.xpath(LOGIN_BUTTON_XPATH)).click();
}

From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java

License:Open Source License

private boolean processRadioButton(String elementType, MethodParameterNode methodParameterNode,
        String argument) {/*from  w w w  .  java  2  s.  com*/

    if (!NodePropertyDefElemType.isRadio(elementType)) {
        return false;
    }

    String findByValue = methodParameterNode
            .getPropertyValue(NodePropertyDefs.PropertyId.PROPERTY_FIND_BY_VALUE_OF_ELEMENT);

    List<WebElement> allOptions = fDriver.findElements(By.name(findByValue));

    for (WebElement option : allOptions) {
        if (clickRadioButton(option, argument)) {
            break;
        }
    }

    return true;
}

From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java

License:Open Source License

private WebElement findWebElementBy(String findByType, String findByValue) {

    checkWebDriver();/*from   w ww . ja  v  a  2 s . c o  m*/

    if (NodePropertyDefFindByType.isId(findByType)) {
        return fDriver.findElement(By.id(findByValue));
    }

    if (NodePropertyDefFindByType.isClassName(findByType)) {
        return fDriver.findElement(By.className(findByValue));
    }

    if (NodePropertyDefFindByType.isTagName(findByType)) {
        return fDriver.findElement(By.tagName(findByValue));
    }

    if (NodePropertyDefFindByType.isTagName(findByType)) {
        return fDriver.findElement(By.tagName(findByValue));
    }

    if (NodePropertyDefFindByType.isName(findByType)) {
        return fDriver.findElement(By.name(findByValue));
    }

    if (NodePropertyDefFindByType.isLinkText(findByType)) {
        return fDriver.findElement(By.linkText(findByValue));
    }

    if (NodePropertyDefFindByType.isPartialLinkText(findByType)) {
        return fDriver.findElement(By.partialLinkText(findByValue));
    }

    if (NodePropertyDefFindByType.isCssSelector(findByType)) {
        return fDriver.findElement(By.cssSelector(findByValue));
    }

    if (NodePropertyDefFindByType.isXPath(findByType)) {
        return fDriver.findElement(By.xpath(findByValue));
    }
    return null;
}

From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java

License:Open Source License

/**
 * Create a new event, with description according the null or empty value.
 * Verify the event name if 'checkEventName' is set to true.
 * /*  w w  w. ja  v  a2s .  c o m*/
 * @param newEventName
 *            the new event name
 * @param eventDescription
 *            the event description
 * @param checkEventName
 *            the check event name
 */
public void triggerNewEvent(final String newEventName, final String eventDescription,
        final boolean checkEventName) {

    logger.info("check if create new event link available.");
    WebElement newEventElement = retrieveElementByLinkText(DriverConfig.getDriver(),
            demandSideManagementConfig.get(NEW_EVENT), SHORT_TIMEOUT);
    DriverConfig.setLogString("click on create new event link.", true);
    newEventElement.click();
    largeWait();
    logger.info("check if create new event form displayed.");
    WebElement formElementPopUp = DriverConfig.getDriver()
            .findElement(By.id(demandSideManagementConfig.get(POPUP_FORM)));
    DateFormat dateFormat = new SimpleDateFormat("yyMMddHHmmss");
    Date date = new Date();
    String dateValue = dateFormat.format(date);

    WaitUtil.waitUntil(5000);
    DriverConfig.setLogString("Enter event name - " + newEventName + dateValue, true);
    formElementPopUp.findElement(By.id(demandSideManagementConfig.get(EVENT_NAME_FIELD)))
            .sendKeys(newEventName + dateValue);
    if (eventDescription != null && !eventDescription.isEmpty()) {
        DriverConfig.setLogString("Enter the description - " + eventDescription + dateValue, true);
        formElementPopUp.findElement(By.name(demandSideManagementConfig.get(EVENT_DESCRIPTION_FIELD)))
                .sendKeys(eventDescription + dateValue);
    }

    logger.info("Verify the event name length.");
    int lengthCheck = formElementPopUp.findElement(By.id(demandSideManagementConfig.get(EVENT_NAME_FIELD)))
            .getAttribute(ATTR_VALUE).length();

    if (checkEventName && lengthCheck == 50) {
        logger.info("Assert the length is not more than 50.", true);
        Assert.assertEquals(lengthCheck == 50, true, "Length is more than 50");
    }

    DriverConfig.setLogString("Save as draft event.", true);
    formElementPopUp.findElement(By.id(demandSideManagementConfig.get(SAVE_DRAFT))).click();
    smallWait();
}

From source file:com.ecofactor.qa.automation.insite.page.SupportLookUpImpl.java

License:Open Source License

/**
 * Do verify pswd reset by new app login.
 * @param userName the user name//from   ww  w.ja v a  2  s .  co m
 * @param tempPassword the temp password
 * @param newPassword the new password
 * @param newAppUrl the new app url
 * @see com.ecofactor.qa.automation.insite.page.SupportLookUp#doVerifyPswdResetByNewAppLogin(java.lang.String,
 *      java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public void doVerifyPswdResetByNewAppLogin(String userName, String tempPassword, String newPassword,
        String newAppUrl) {

    /*
     * WebDriver popup = null; Set<String> windowids =
     * DriverConfig.getDriver().getWindowHandles(); Iterator<String> iter =
     * windowids.iterator(); iter.next();
     * DriverConfig.setLogString("Switch to other window and verify the title", true); popup =
     * DriverConfig.getDriver().switchTo().window((String) iter.next()); smallWait(); iter =
     * windowids.iterator(); if (iter.hasNext()) { checkConsumerNewPasswordTrigger(userName,
     * tempPassword); doConsumerChangePassword(tempPassword, newPassword); doConsumerlogout();
     * loginConsumerPortal(userName, newPassword); doConsumerlogout(); popup.close(); // switch
     * to main window DriverConfig.setLogString("Switch to main window", true);
     * DriverConfig.getDriver().switchTo().window((String) iter.next()); }
     */
    DriverConfig.setLogString("Load URL : " + newAppUrl, true);
    DriverConfig.getDriver().get(newAppUrl);
    mediumWait();
    DriverConfig.setLogString("Enter UserName and Password", true);
    clearAndInput(DriverConfig.getDriver(), By.name("username"), userName);
    clearAndInput(DriverConfig.getDriver(), By.name("password"), tempPassword);
    tinyWait();
    DriverConfig.setLogString("Click Login", true);
    DriverConfig.getDriver().findElement(By.className("login_submit")).click();
    largeWait();
    DriverConfig.setLogString("Enter temporary Password : " + tempPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_old_password"), tempPassword);
    tinyWait();
    DriverConfig.setLogString("Enter New Password : " + newPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_new_password"), newPassword);
    tinyWait();
    DriverConfig.setLogString("Re-Enter New Password : " + newPassword, true);
    clearAndInput(DriverConfig.getDriver(), By.className("input_confirm_new_password"), newPassword);
    tinyWait();
    DriverConfig.setLogString("Click Continue", true);
    DriverConfig.getDriver().findElement(By.className("continueButton")).click();
    smallWait();
    DriverConfig.setLogString("Check HelpOverlay Page displayed", true);
    isDisplayedByClassName(DriverConfig.getDriver(), "help_slide", SHORT_TIMEOUT);
    while (!isDisplayedByClassName(DriverConfig.getDriver(), "close_ftux_button", SHORT_TIMEOUT)) {
        DriverConfig.setLogString("Click Next.", true);
        DriverConfig.getDriver().findElement(By.className("slick-next")).click();
    }
    DriverConfig.setLogString("Click GetStarted", true);
    DriverConfig.getDriver().findElement(By.className("close_ftux_button")).click();
    tinyWait();
    DriverConfig.setLogString("Click Logout", true);
    DriverConfig.getDriver().findElement(By.cssSelector("div.menu_row.logout")).click();
    assertTrue(isDisplayedByClassName(DriverConfig.getDriver(), "login_submit", SHORT_TIMEOUT),
            "Login Page Not Loaded Successfully");

}

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

License:Open Source License

/**
 * Filter criteria.//from   www. j av a  2  s.com
 * @param criteriaString the criteria string
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminHomePage#filterCriteria(java.lang.String)
 */
public void filterCriteria(String criteriaString) {

    isPageLoaded();
    setLogString("Enter criteria to filter." + criteriaString, true);
    isDisplayed(driverManager.getAdminDriver(), By.name(CRITERIA), SHORT_TIMEOUT);
    final WebElement criteriaText = getElement(driverManager.getAdminDriver(), By.name(CRITERIA), TINY_TIMEOUT);
    criteriaText.sendKeys(criteriaString);
    final WebElement searchbutton = getElementBySubElementAttr(driverManager.getAdminDriver(), formElement,
            By.tagName(TAG_INPUT), ATTR_VALUE, SEARCH, SHORT_TIMEOUT);
    searchbutton.click();
    smallWait();
}

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

License:Open Source License

/**
 * login//w w w  . jav  a  2s .c o  m
 * @see com.ecofactor.qa.automation.newapp.admin.page.AdminLoginPage#login()
 */
@Override
public void login() {

    loadPage();

    LogUtil.setLogString("Login to Admin Portal Page", true);
    LogUtil.setLogString("Check Username textField is displayed", true);
    clearAndInput(driverManager.getAdminDriver(), By.name(USER_NAME_FIELD), mobileConfig.get(ADMIN_USERNAME));
    LogUtil.setLogString("Enter Username :" + mobileConfig.get(ADMIN_USERNAME), true);

    LogUtil.setLogString("Check Password field is displayed", true);
    clearAndInput(driverManager.getAdminDriver(), By.name(PASSWORD_FIELD), mobileConfig.get(ADMIN_PASSWORD));
    LogUtil.setLogString("Enter Password :" + mobileConfig.get(ADMIN_PASSWORD), true);

    LogUtil.setLogString("Click Continue Button", true);
    isDisplayed(driverManager.getAdminDriver(), By.id(CONTINUE_BTN), TINY_TIMEOUT);
    final WebElement continueBtn = getElement(driverManager.getAdminDriver(), By.id(CONTINUE_BTN),
            TINY_TIMEOUT);
    continueBtn.click();
}

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

License:Open Source License

/**
 * Entering the userName and password in fields.
 * @param userName the user name/*  w  w w . j a va 2 s  .c o m*/
 * @param password the password
 * @see com.ecofactor.qa.automation.newapp.page.LoginPage#userNamePasswordFields(java.lang.String,
 *      java.lang.String)
 */
@Override
public void userNamePasswordFields(String userName, String password) {

    getAction().rejectAlert();
    LogUtil.setLogString(LogSection.START, "Login Starts", true);
    LogUtil.setLogString("Check Username textField is displayed", true, CustomLogLevel.HIGH);
    WebElement userElement = getElement(getDriver(), By.name(USERNAME), TINY_TIMEOUT);
    WaitUtil.waitUntil(300);
    userElement.sendKeys(userName);
    // clearAndInput(getDriver(), By.name(USERNAME), userName);
    LogUtil.setLogString("Enter Username :" + userName, true, CustomLogLevel.LOW);

    LogUtil.setLogString("Check Password field is displayed", true, CustomLogLevel.HIGH);
    clearAndInput(getDriver(), By.name(PASSWORD), password);
    LogUtil.setLogString("Enter Password :" + password, true, CustomLogLevel.LOW);
}

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

License:Open Source License

/**
 * Click login./*  w ww  .  j a  v a  2  s .  c o  m*/
 * @param userName the user name
 * @param password the password
 * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickLogin(java.lang.String)
 */
public void clickLogin(String userName, String password) {

    LogUtil.setLogString("Enter Username :" + userName, true);
    clearAndInput(getDriver(), By.name(USERNAME), userName);

    LogUtil.setLogString("Enter Password :" + password, true);
    clearAndInput(getDriver(), By.name(PASSWORD), password);

    LogUtil.setLogString("Click Login", true);
    final WebElement loginBtn = getElement(getDriver(), By.className(LOGIN_SUBMIT), TINY_TIMEOUT);
    getAction().click(loginBtn);
    WaitUtil.oneSec();
    getAction().rejectAlert();
    setLoggedIn(isLoadingIconNotDisplayed());
    setLoggedInUser(userName);
}

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

License:Open Source License

/**
 * Checks if is not login page./* w w w . j  av a  2s.com*/
 * @return true, if is not login page
 */
private boolean isNotLoginPage() {

    return isNotDisplayed(getDriver(), By.name(USERNAME), TINY_TIMEOUT)
            && isNotDisplayed(getDriver(), By.name(PASSWORD), TINY_TIMEOUT)
            && isNotDisplayed(getDriver(), By.className(LOGIN_SUBMIT), TINY_TIMEOUT);
}