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.epam.jdi.uitests.mobile.appium.elements.pageobjects.annotations.AppiumAnnotationsUtil.java

License:Open Source License

public static By findByToBy(FindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;//from  ww w  .ja v  a  2 s.  c  o  m
}

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

License:Open Source License

public static By getFindByLocator(JFindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;//from   w  ww  .ja v  a  2s.co m
}

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

License:Open Source License

public static By findByToBy(JFindBy locator) {
    if (locator == null)
        return null;
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());
    return null;//www  . j  ava 2s  .  c  o  m
}

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(FindBy locator) {
    if (locator == null)
        return null;
    if (!locator.id().isEmpty())
        return By.id(locator.id());
    if (!locator.className().isEmpty())
        return By.className(locator.className());
    if (!locator.xpath().isEmpty())
        return By.xpath(locator.xpath());
    if (!locator.css().isEmpty())
        return By.cssSelector(locator.css());
    if (!locator.linkText().isEmpty())
        return By.linkText(locator.linkText());
    if (!locator.name().isEmpty())
        return By.name(locator.name());
    if (!locator.partialLinkText().isEmpty())
        return By.partialLinkText(locator.partialLinkText());
    if (!locator.tagName().isEmpty())
        return By.tagName(locator.tagName());
    return null;/*from ww w. ja  v  a 2  s .  c o m*/
}

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(ByName locator) {
    if (locator == null)
        return null;
    return By.name(locator.value());
}

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

License:Open Source License

public static By findByToBy(JFindBy locator) {
    if (locator == null)
        return null;

    if (!"".equals(locator.xpath()))
        return By.xpath(locator.xpath());
    if (!"".equals(locator.css()))
        return By.cssSelector(locator.css());
    if (!"".equals(locator.linkText()))
        return By.linkText(locator.linkText());
    if (!"".equals(locator.partialLinkText()))
        return By.partialLinkText(locator.partialLinkText());
    if (!"".equals(locator.tagName()))
        return By.tagName(locator.tagName());

    if (!"".equals(locator.text()))
        return By.xpath(".//*/text()[normalize-space(.) = " + Quotes.escape(locator.text()) + "]/parent::*");

    if (!"".equals(locator.attribute().name()))
        return getAttribute(locator.attribute().name(), locator.attribute().value());
    if (!"".equals(locator.id()))
        return By.id(locator.id());
    if (!"".equals(locator.className()))
        return By.className(locator.className());
    if (!"".equals(locator.name()))
        return By.name(locator.name());
    if (!"".equals(locator.value()))
        return getAttribute("value", locator.value());
    if (!"".equals(locator.title()))
        return getAttribute("title", locator.title());
    if (!"".equals(locator.type()))
        return getAttribute("type", locator.title());
    if (!"".equals(locator.model()))
        return getAttribute("ng-model", locator.model());
    if (!"".equals(locator.binding()))
        return getAttribute("ng-binding", locator.binding());
    if (!"".equals(locator.repeat()))
        return getAttribute("ng-repeat", locator.repeat());
    return null;//  w  w w . j a  va 2 s .  c om
}

From source file:com.etouch.taf.webui.selenium.test.AndroidHybridAppTest.java

@Test
public void testWebViewWithAndroidDriver() throws InterruptedException, MalformedURLException {
    driverObj.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    Thread.sleep(4000);//from w w w.  jav a 2 s. c o m

    //Click on Activity tracker license link
    driverObj.findElement(By.name(prop.getProperty("ihs_activity_tracker_Activity_Tracker_License_Link")))
            .click();

    //Entered in to WebView

    Thread.sleep(2000);
    //wd.context("WEBVIEW_1");

    //Thread.sleep(2000);

    //Click on Search Text box
    WebElement search = driverObj
            .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Link")));
    search.click();

    //Enter Search Text
    WebElement searchText = driverObj
            .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Textbox")));
    searchText.sendKeys("wells");

    //Click on Search Button
    WebElement searchButton = driverObj
            .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Button")));
    searchButton.click();

    Thread.sleep(4000);

    //navigate back to App view      
    driverObj.navigate().back();
    Thread.sleep(2000);

    driverObj.navigate().back();
    Thread.sleep(2000);

    //Entered in to Native view
    driverObj.context("NATIVE_APP");
    Thread.sleep(2000);

    //Click on login button
    //WebElement login=driverObj.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[1]/android.widget.Button[1]"));
    WebElement login = driverObj.findElement(By.id(prop.getProperty("ihs_activity_tracker_login_button")));
    login.click();

    Thread.sleep(3000);

}

From source file:com.example.selenium.find.elements.FindElementsTest.java

@Test
public void findByName() {

    try {//from  w w  w  . java 2 s  .  c o  m
        WebElement element = selenium.findElement(By.name("email"));
        Assert.assertNotNull(element);
    } catch (NoSuchElementException ex) {
        Logger.getLogger(FindElementsTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.example.selenium.find.elements.FindElementsTest.java

@Test
public void findByNestedElement() {
    try {/*w  ww  . j  a v  a2  s. c  o m*/
        WebElement element = selenium.findElement(By.id("div1")).findElement(By.name("email"));
        Assert.assertNotNull(element);
    } catch (NoSuchElementException ex) {
        Logger.getLogger(FindElementsTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.example.selenium.grid.SeleniumGridChrome.java

@Test(dataProvider = "xlsTest")
public void testLogin(String useName, String password) throws InterruptedException {

    driver.get("http://localhost:8080/WebApplication/pages/login.html");
    WebElement userNameText = driver.findElement(By.name("email"));
    userNameText.sendKeys(useName);// ww w.j ava2s. c  o  m

    WebElement passwordText = driver.findElement(By.id("password"));
    passwordText.sendKeys(password);

    WebElement loginButton = driver.findElement(By.linkText("Login"));
    loginButton.click();
    if (driver.getTitle().equals("SB Admin 2 - Bootstrap Admin Theme")) {
        assertTrue(true);
    } else {
        assertTrue(false);
    }
}