Example usage for org.openqa.selenium By tagName

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

Introduction

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

Prototype

public static By tagName(String tagName) 

Source Link

Usage

From source file:ch.vorburger.mifos.wiki.ZWikiScraper.java

License:Apache License

/**
 * Go to the edit page./*from   w ww.j  a  va  2  s  .  c  o m*/
 * Does the login, if needed.
 * @param pageID zWiki Page ID
 */
private boolean wdGoToEdit(String pageID) {
    String url = wikiBaseURL + pageID + "/editform";
    wd.get(url);
    System.out.println(wd.getCurrentUrl()); // TODO Remove
    try {
        wd.findElement(By.tagName("textarea"));
        // So we're really on the edit page, so return.  
        return true;
    } catch (NoSuchElementException e1) {
        try {
            // We landed on the Plone login page instead of the Wiki edit, so let's login:
            wd.findElement(By.id("__ac_name")).sendKeys(wikiLoginName);
            wd.findElement(By.id("__ac_password")).sendKeys(wikiPassword);
            wd.findElement(By.name("submit")).click();
            // Now textarea must be found (if the login was valid) ...
            // if we have a NoSuchElementException again here, something is wrong
        } catch (NoSuchElementException e2) {
            // Actually not a login page :( This happens if the TOC has an invalid page ID entry
            return false;
        }
        try {
            wd.findElement(By.tagName("textarea"));
            return true;
        } catch (NoSuchElementException e2) {
            System.out.println(wd.getCurrentUrl());
            System.out.println(wd.getTitle());
            System.out.println(wd.getPageSource());
            throw new IllegalStateException(
                    "I am not on the Wiki Edit page as I should be by now, abandoning...");
        }
    }

}

From source file:ch.vorburger.mifos.wiki.ZWikiScraper.java

License:Apache License

List<WikiNode> getContents() {
    List<WikiNode> rootNodes = new LinkedList<ZWikiScraper.WikiNode>();

    wd.get(wikiBaseURL + "/FrontPage/contents");
    WebElement all = wd.findElement(By.className("formcontent"));
    WebElement tree = all.findElement(By.tagName("ul"));
    rootNodes.addAll(ulToNodes(tree, null));

    WebElement singletonFlatList = all.findElement(By.tagName("div")).findElement(By.tagName("ul"));
    rootNodes.addAll(ulToNodes(singletonFlatList, null));

    return rootNodes;
}

From source file:ch.vorburger.mifos.wiki.ZWikiScraper.java

License:Apache License

private List<WikiNode> ulToNodes(WebElement subElements, WikiNode parent) {
    List<WikiNode> nodes = new LinkedList<ZWikiScraper.WikiNode>();

    List<WebElement> lis = subElements.findElements(By.xpath("li"));
    for (WebElement li : lis) {
        WebElement ahref = li.findElement(By.tagName("span")).findElement(By.tagName("a"));
        String href = ahref.getAttribute("href");
        String pageID = wikiURL2PageId(href);
        WikiNode n = new WikiNode();
        n.pageID = pageID;/*  w  w w  . ja v  a  2 s  .  co m*/
        n.parentNode = parent;

        try {
            WebElement ul = li.findElement(By.tagName("ul"));
            n.childNodes.addAll(ulToNodes(ul, n));
        } catch (NoSuchElementException e) {
            // No children then, OK.
        }

        nodes.add(n);
    }

    return nodes;
}

From source file:cn.newtouch.util.test.utils.SeleniumUtils.java

License:Apache License

/**
 * Selnium1.0./*from   w  ww  . java2  s . com*/
 */
public static boolean isTextPresent(WebDriver driver, String text) {
    return StringUtils.contains(driver.findElement(By.tagName("body")).getText(), text);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.ContenedorWebTest.java

@Test
public void testDesactivarMaquina() throws Exception {

    Thread.sleep(2000);/*from w  w w. j a v a  2s.  c  o m*/

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/contenedorWeb.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.MaquinaVirtualTest.java

@Test
public void testDesactivarMaquina() throws Exception {

    Thread.sleep(2000);/*from   w  w  w  .ja v  a  2 s. c o m*/

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/maquinaVirtual.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.MySQLTest.java

@Test
public void testDesactivarMaquina() throws Exception {

    Thread.sleep(2000);//from w  w  w .  ja  va  2 s. c  om

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/mySQL.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.PaginaWebTest.java

@Test
public void testDesactivarPagina() throws Exception {

    Thread.sleep(2000);//from   ww  w . j  a v a2 s  .c  o m

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/paginaWeb.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.RepositorioTest.java

@Test
public void testDesactivarMaquina() throws Exception {

    Thread.sleep(2000);//from   w  w  w .  j av a2s. co  m

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/repositorio.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}

From source file:co.edu.uniandes.csw.RigitalApp.test.SoftwareSalasTest.java

@Test
public void testDesactivarMaquina() throws Exception {

    Thread.sleep(2000);/* w  ww . j  a va  2s .  co  m*/

    List<WebElement> table = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));

    for (WebElement webElement : table) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(3).getText().equals("true")) {
            elems.get(0).findElement(By.tagName("input")).click();
        }
    }
    Thread.sleep(2000);
    driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click();

    driver.get(baseUrl + "/RigitalApp.web/softwareSalas.html");
    Thread.sleep(2000);
    List<WebElement> table2 = driver
            .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr"));
    boolean def = true;
    for (WebElement webElement : table2) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        String val = elems.get(3).getText();
        boolean temp = !val.equals("true");
        System.out.println(temp);
        def = def && temp;
    }
    Thread.sleep(4000);
    assertTrue(def);
}