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:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java

protected void targetTableData() {
    Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30);
    JavascriptExecutor jse = (JavascriptExecutor) getDriver();
    //if(index>0)
    jse.executeScript("window.scrollBy(0,-800)", "");
    getWebElement_By_xpath("//*[@id='content']/div[9]/div[1]/div[2]/ul/li[1]").click();

    jse.executeScript("window.scrollBy(0,800)", "");
    waittable.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='details-table']")));

    WebElement headertable = getDriver().findElement(By.xpath("//*[@id='details-table']"));
    List<WebElement> header = headertable.findElements(By.xpath("//*[@id='billhistory']/tr"));
    System.out.println("===========Table Data========");

    // And iterate over them, getting the header data
    for (WebElement node : header) {
        List<WebElement> cells = node.findElements(By.tagName("th"));

        for (WebElement cell : cells)
            headerlist.add(cell.getText());
    }/*from   www  . j  a  v a 2s.c o m*/
    // Now get all the TR elements from the table
    WebElement table = getDriver().findElement(By.xpath("//*[@id='details-table']/tbody"));
    List<WebElement> rows = table.findElements(By.tagName("tr"));
    // And iterate over them, getting the cells
    for (WebElement row : rows) {
        List<WebElement> rowcells = row.findElements(By.tagName("td"));

        for (WebElement cell : rowcells)
            tabledatalist.add(cell.getText());
    }
}

From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Broadband_Util.java

/** Reads the header data after selecting
 * different options from dropdown list//from  ww  w  .  java2s .  c  om
 **/
protected void targetTableEventData() throws InterruptedException {
    Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30);
    JavascriptExecutor jse = (JavascriptExecutor) getDriver();
    List<WebElement> speechbubble = null;

    boolean breakit;
    while (true) {
        breakit = true;
        try {

            getWebElement_By_xpath("//*[@id='content']/div[9]/div[1]/div[2]/ul/li[2]/a").click();
            jse.executeScript("window.scrollBy(0,240)", "");
            waittable
                    .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='details-table']")));

            getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
            speechbubble = getDriver().findElements(By.xpath("//*[@id='column-filter-1']/ul/li"));
            System.out.println("Number of ChildNodes :" + speechbubble.size());
        } catch (Exception e) {
            //e.printStackTrace();
            breakit = false;
        }
        if (breakit == true) {
            break;
        }
    }
    //jse.executeScript("window.scrollBy(0,100)", "");    

    // Map<String,List<String>> testHeaderMap = new HashMap <String,List<String>>();
    //List<String> lsheaderTableKey = new ArrayList<String>() ; 
    List<String> lsheaderdata = null;
    int speechbubbleSize = speechbubble.size();
    String arHeaderKey[] = new String[speechbubbleSize];

    String headerKeyStr = "";
    for (int k = 0; k < speechbubbleSize; k++) {
        while (true) {
            breakit = true;
            try {
                jse.executeScript("window.scrollBy(0,50)", "");

                //click the dropdown control
                waittable.until(ExpectedConditions
                        .visibilityOfElementLocated(By.xpath("//*[@id='column-filter-sb']/span[2]")));
                getDriver().findElement(By.xpath("//*[@id='column-filter-sb']/span[2]")).click();

                int j = k + 1;

                String nodepath = "//*[@id='column-filter-1']/ul/li" + "[" + j + "]" + "/label";
                waittable.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(nodepath)));
                WebElement childElementSub = getDriver().findElement(By.xpath(nodepath));
                System.out.println("Id :'" + j + "' " + childElementSub.getText());
                String headertableKey = childElementSub.getText();
                //lsheaderTableKey.add(headertableKey);
                headerKeyStr = headerKeyStr + headertableKey + AppConstants.COMMA;
                childElementSub.click(); //click the checkbox

                //click the update button
                waittable.until(ExpectedConditions
                        .visibilityOfElementLocated(By.xpath("//*[@id='speechBubble']/div[3]/button")));
                getDriver().findElement(By.xpath("//*[@id='speechBubble']/div[3]/button")).click();
                getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

                //System.out.println("Id :'" +j+"' Update Button Clicked" );

                //Read the bill history table header data - begin
                waittable.until(
                        ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='details-table']")));
                WebElement headertable = getDriver().findElement(By.xpath("//*[@id='details-table']"));
                int i = 0;
                waittable.until(
                        ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='billhistory']/tr")));
                List<WebElement> header = headertable.findElements(By.xpath("//*[@id='billhistory']/tr"));

                // And iterate over them, getting the header data
                for (WebElement node : header) {
                    List<WebElement> cells = node.findElements(By.tagName("th"));
                    lsheaderdata = new ArrayList<String>();
                    for (WebElement cell : cells) {
                        //System.out.println("header"+cell.getText());
                        String headerData = cell.getText();
                        lsheaderdata.add(headerData);
                    }
                }

                //Read the bill history table header data - ends

                jse.executeScript("window.scrollBy(0,-50)", "");
            } catch (Exception e) {
                //e.printStackTrace();
                breakit = false;
            }
            if (breakit == true) {
                int indexPos = headerKeyStr.lastIndexOf(AppConstants.COMMA);
                String data = headerKeyStr.substring(0, indexPos);
                arHeaderKey[k] = data;
                System.out.println("lsheaderTableKey : " + data);
                dropDownTableHeaderMap.put(arHeaderKey[k], lsheaderdata);
                break;
            }
        } //end  while
    } //end for

    System.out.println("DropDown Control Data : " + dropDownTableHeaderMap);

}

From source file:com.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java

protected void targetTableData() {
    Wait<WebDriver> waittable = new WebDriverWait(getDriver(), 30);

    JavascriptExecutor jse = (JavascriptExecutor) getDriver();

    jse.executeScript("window.scrollBy(0,-800)", "");
    //getWebElement_By_xpath("//*[@id='content']/div[9]/div[1]/div[2]/ul/li["+(x+1)+"]").click();
    //handleLink_ByText(AppConstants.DAYS_60);
    jse.executeScript("window.scrollBy(0,800)", "");

    waittable.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='details-table']")));

    WebElement headertable = getDriver().findElement(By.xpath("//*[@id='details-table']"));
    //int i=0;//from   ww  w.j av a 2  s. c  om
    List<WebElement> header = headertable.findElements(By.xpath("//*[@id='billhistory']/tr"));

    System.out.println("===========Table Data========");
    // And iterate over them, getting the header data
    for (WebElement node : header) {
        List<WebElement> cells = node.findElements(By.tagName("th"));
        ;
        for (WebElement cell : cells) {

            headerList.add(cell.getText());
        }

        WebElement table = getDriver().findElement(By.xpath("//*[@id='details-table']/tbody"));
        List<WebElement> rows = table.findElements(By.tagName("tr"));
        // And iterate over them, getting the cells
        for (WebElement row : rows) {
            List<WebElement> rowcells = row.findElements(By.tagName("td"));

            for (WebElement cell : rowcells) {

                tableDataList.add(cell.getText());

            }
        }
    }
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void findElementByTagName() {
    WebElement element = driver.findElement(By.tagName("input"));
    Assert.assertEquals("INPUT", element.getTagName());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void Element_findElementByTagName() {
    WebElement parent = driver.findElement(By.id("form"));
    WebElement element = parent.findElement(By.tagName("input"));
    Assert.assertEquals("INPUT", element.getTagName());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void findElementsByTagName() {
    List<WebElement> found = driver.findElements(By.tagName("input"));
    Assert.assertEquals(2, found.size());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void Element_findElementsByTagName() {
    WebElement parent = driver.findElement(By.id("form"));
    List<WebElement> found = parent.findElements(By.tagName("input"));
    Assert.assertEquals(2, found.size());
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansQuestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for Quest lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_Quest_lab() throws Throwable {
    Thread.sleep(2000);//  w  w  w  .  ja  v a 2  s .c o  m

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Click on the Phisician icon on the LabClient list page for West lab$")
public void click_on_the_Phisician_icon_on_the_LabClient_list_page_for_West_lab() throws Throwable {
    Thread.sleep(2000);/*from   ww  w.  j a v  a 2 s.c  om*/

    WebElement table = driver.findElement(By.id("example"));

    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals(LAB_CLIENT)) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-user-md.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}

From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansWestSteps.java

@When("^Select 'Edit' icon next to 'Angelina' physician$")
public void select_Edit_icon_next_to_Angelina_physician() throws Throwable {
    Thread.sleep(2000);/*from w  w  w.  ja v a2  s. com*/

    WebElement table = driver.findElement(By.id("example"));
    List<WebElement> allRows = table.findElements(By.tagName("tr"));
    loop: {
        for (WebElement row : allRows) {
            List<WebElement> cells = row.findElements(By.xpath("./*"));
            for (WebElement cell : cells) {
                String cellText = cell.getText();
                if (cellText.equals("Angelia")) {
                    WebElement icon = row.findElement(By.cssSelector(".fa.fa-pencil-square-o.fa-2x"));
                    icon.click();
                    break loop;
                }
            }
        }
    }
    Thread.sleep(2000);
}