Example usage for org.openqa.selenium WebElement getText

List of usage examples for org.openqa.selenium WebElement getText

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement getText.

Prototype

String getText();

Source Link

Document

Get the visible (i.e.

Usage

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/*  w w  w. j a va 2  s. c  o m*/
 **/
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

/**
 * Read the 30Days Graph data/*from w  ww . j av a 2  s.c o m*/
 */
protected void targetGraphData_30Days() {
    JavascriptExecutor jse = (JavascriptExecutor) getDriver();

    //scroll down the page 
    jse.executeScript("window.scrollBy(0,-500)", "");

    handleLink_ByText(AppConstants.DAYS_30);
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), 15);
    //JavascriptExecutor jse = (JavascriptExecutor)getDriver();
    Map<String, String> mapbill = new HashMap<String, String>();
    jse.executeScript("window.scrollBy(0,225)", "");
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]")));
    //Working :get the stroke attribute to get the color value of graph
    //getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    boolean breakIt = true;

    //Get the BillCycle Elements
    String billcyclerootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]";
    WebElement billcyclerootElement = getDriver().findElement(By.xpath(billcyclerootNodeXpath));

    String billcyclechildXpath = "./*[name()='text']";

    List<WebElement> listbillcyclechild = billcyclerootElement.findElements(By.xpath(billcyclechildXpath));

    int eleListSize = listbillcyclechild.size();
    System.out.println("listChildElements.size() : " + listbillcyclechild.size());

    //Get the BillCycle Graph , tooltip Elements
    String bcGraphRootNodeXpath = "//*[name()='svg']/*[name()='g'][6]/*[name()='g']";
    WebElement bcGraphRootElement = getDriver().findElement(By.xpath(bcGraphRootNodeXpath));

    String bcGraphChildXpath = "./*[name()='g']";

    List<WebElement> listbcGraphChild = bcGraphRootElement.findElements(By.xpath(bcGraphChildXpath));
    int bcGraphListSize = listbcGraphChild.size();
    if (bcGraphListSize > 0) {
        targetBCGraphData_30Days = new HashMap();
    }
    // System.out.println("bcGraphListSize.size() : " + listbcGraphChild.size());

    for (int j = 0; j < eleListSize; j++) {
        int n = j + 1;
        String billCycleDate = null;
        String bcAtrribute_color = null;
        while (true) {
            breakIt = true;
            try {

                //read the billcycle data from nodes 
                String billchildNodePath_startDate = billcyclerootNodeXpath.concat("/*[name()='text']")
                        .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan']"));
                WebElement billelement_Date = getDriver().findElement(By.xpath(billchildNodePath_startDate));

                billCycleDate = billelement_Date.getText();

                if ((billCycleDate.trim().length() > 0)
                        && (!(targetGraphBillCycleDate_30Days.contains(billCycleDate)))) {
                    targetGraphBillCycleDate_30Days.add(billCycleDate);
                    System.out.println("Bill Cycle : '" + n + "' -->" + billCycleDate);
                }

                //read the billcycle graph data - color  from nodes
                String billchildNodePath_color = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[")
                        .concat(String.valueOf(n).concat("]").concat("/*[name()='path']"));
                //System.out.println("Node billchildNodePath_color : " + billchildNodePath_color);
                WebElement billelement_color = getDriver().findElement(By.xpath(billchildNodePath_color));

                bcAtrribute_color = billelement_color.getAttribute("stroke");

            } catch (Exception e) {
                if (e.getMessage().contains("element is not attached")) {
                    //System.out.println("Error: Element 4 ");
                    breakIt = false;
                }
            }
            if (breakIt) {
                break;
            }

        } //while loop ends
        targetBCGraphData_30Days.put(Integer.toString(n), bcAtrribute_color);
    } //for loop ends
}

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

/**
 * Read the 90Days Graph data/*from  ww  w .  j a va 2 s.  co m*/
 */
protected void targetGraphData_90Days() {
    JavascriptExecutor jse = (JavascriptExecutor) getDriver();

    //scroll up the page 
    jse.executeScript("window.scrollBy(0,-500)", "");
    handleLink_ByText(AppConstants.DAYS_90);
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), 30);
    Map<String, String> mapbill = new HashMap<String, String>();
    jse.executeScript("window.scrollBy(0,225)", "");
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]")));
    //Working :get the stroke attribute to get the color value of graph
    getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    boolean breakIt = true;

    //Get the BillCycle Elements
    String billcyclerootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]";
    WebElement billcyclerootElement = getDriver().findElement(By.xpath(billcyclerootNodeXpath));
    String billcyclechildXpath = "./*[name()='text']";
    List<WebElement> listbillcyclechild = billcyclerootElement.findElements(By.xpath(billcyclechildXpath));
    int eleListSize = listbillcyclechild.size();
    // System.out.println("listChildElements.size() : " + listbillcyclechild.size());

    //Get the BillCycle Graph , tooltip Elements
    String bcGraphRootNodeXpath = "//*[name()='svg']/*[name()='g'][6]/*[name()='g']";
    WebElement bcGraphRootElement = getDriver().findElement(By.xpath(bcGraphRootNodeXpath));

    String bcGraphChildXpath = "./*[name()='g']";

    List<WebElement> listbcGraphChild = bcGraphRootElement.findElements(By.xpath(bcGraphChildXpath));
    int bcGraphListSize = listbcGraphChild.size();
    if (bcGraphListSize > 0) {
        targetBCGraphData_90Days = new HashMap();
    }
    // System.out.println("bcGraphListSize.size() : " + listbcGraphChild.size());

    for (int j = 0; j < eleListSize; j++) {
        int n = j + 1;
        Map<String, String> tempBCGData = new HashMap();
        String billCycleDate = null;
        String bcAtrribute_color = null;
        while (true) {
            breakIt = true;
            try {

                //read the billcycle data from nodes 
                String billchildNodePath_startDate = billcyclerootNodeXpath.concat("/*[name()='text']")
                        .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][1]"));
                WebElement billelement_startDate = getDriver()
                        .findElement(By.xpath(billchildNodePath_startDate));
                //Thread.sleep(2000);
                String billAtrribute_startDate = billelement_startDate.getText();

                String billchildNodePath_endDate = billcyclerootNodeXpath.concat("/*[name()='text']")
                        .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][2]"));
                WebElement billelement_endDate = getDriver().findElement(By.xpath(billchildNodePath_endDate));

                String billAtrribute_endDate = billelement_endDate.getText();

                billCycleDate = billAtrribute_startDate.concat("_").concat(billAtrribute_endDate);
                //System.out.println("Bill Cycle : '" + n+"' -->"+  billCycleDate);

                //read the billcycle graph data - color, tooltip from nodes
                String billchildNodePath_color = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[")
                        .concat(String.valueOf(n).concat("]").concat("/*[name()='path']"));
                //System.out.println("Node billchildNodePath_color : " + billchildNodePath_color);
                WebElement billelement_color = getDriver().findElement(By.xpath(billchildNodePath_color));

                bcAtrribute_color = billelement_color.getAttribute("stroke");
                String colorMap = AppConstants.COLOR.concat(AppConstants.BEGIN_BRACKET).concat(billCycleDate)
                        .concat(AppConstants.CLOSE_BRACKET);
                tempBCGData.put(colorMap, bcAtrribute_color);
                Actions builder = new Actions(getDriver());

                String childMouseHouverNode = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[")
                        .concat(String.valueOf(n).concat("]"));
                builder.moveToElement(getDriver().findElement(By.xpath(childMouseHouverNode))).perform();

                WebElement mouseHoverNodeElement = getDriver()
                        .findElement(By.xpath("//div[9]/div[1]/div[1]/div[2]/div/div/div"));

                if (mouseHoverNodeElement != null) {
                    String toolTipText = mouseHoverNodeElement.getText();
                    System.out.println("toolTipText : '" + n + "' " + toolTipText);
                    String toolTipTextMap = AppConstants.TOOL_TIP_TEXT.concat(AppConstants.BEGIN_BRACKET)
                            .concat(billCycleDate).concat(AppConstants.CLOSE_BRACKET);
                    tempBCGData.put(toolTipTextMap, toolTipText.replaceAll("\n", ""));
                    builder.moveToElement(getDriver().findElement(By.xpath(billchildNodePath_startDate)))
                            .click().perform();
                }

            } catch (Exception e) {
                if (e.getMessage().contains("element is not attached")) {
                    //System.out.println("Error: Element 4 ");
                    breakIt = false;
                }
            }
            if (breakIt) {
                break;
            }

        } //while loop ends
        targetBCGraphData_90Days.put(billCycleDate, tempBCGData);
    } //for loop ends
}

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

/**
 * Read the 60Days Graph data//from   ww w  .j  av a2  s .  com
 */
protected void targetGraphData_60Days() {
    JavascriptExecutor jse = (JavascriptExecutor) getDriver();

    handleLink_ByText(AppConstants.DAYS_60);
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), 60);
    Map<String, String> mapbill = new HashMap<String, String>();
    jse.executeScript("window.scrollBy(0,-500)", "");
    jse.executeScript("window.scrollBy(0,225)", "");
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.xpath("//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]")));
    //Working :get the stroke attribute to get the color value of graph
    getDriver().manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    boolean breakIt = true;

    //Get the BillCycle Elements
    String billcyclerootNodeXpath = "//*[name()='svg']/*[name()='g'][13]/*[name()='g'][1]";
    WebElement billcyclerootElement = getDriver().findElement(By.xpath(billcyclerootNodeXpath));

    String billcyclechildXpath = "./*[name()='text']";

    List<WebElement> listbillcyclechild = billcyclerootElement.findElements(By.xpath(billcyclechildXpath));

    int eleListSize = listbillcyclechild.size();
    // System.out.println("listChildElements.size() : " + listbillcyclechild.size());

    //Get the BillCycle Graph , tooltip Elements
    String bcGraphRootNodeXpath = "//*[name()='svg']/*[name()='g'][6]/*[name()='g']";
    WebElement bcGraphRootElement = getDriver().findElement(By.xpath(bcGraphRootNodeXpath));

    String bcGraphChildXpath = "./*[name()='g']";

    List<WebElement> listbcGraphChild = bcGraphRootElement.findElements(By.xpath(bcGraphChildXpath));
    int bcGraphListSize = listbcGraphChild.size();
    if (bcGraphListSize > 0) {
        targetBCGraphData_60Days = new HashMap();
    }
    // System.out.println("bcGraphListSize.size() : " + listbcGraphChild.size());

    for (int j = 0; j < eleListSize; j++) {
        int n = j + 1;
        Map<String, String> tempBCGData = new HashMap();
        String billCycleDate = null;
        String bcAtrribute_color = null;
        while (true) {
            breakIt = true;
            try {

                //read the billcycle data from nodes 
                String billchildNodePath_startDate = billcyclerootNodeXpath.concat("/*[name()='text']")
                        .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][1]"));
                WebElement billelement_startDate = getDriver()
                        .findElement(By.xpath(billchildNodePath_startDate));
                //Thread.sleep(2000);
                String billAtrribute_startDate = billelement_startDate.getText();

                String billchildNodePath_endDate = billcyclerootNodeXpath.concat("/*[name()='text']")
                        .concat("[").concat(String.valueOf(n).concat("]").concat("/*[name()='tspan'][2]"));
                WebElement billelement_endDate = getDriver().findElement(By.xpath(billchildNodePath_endDate));

                String billAtrribute_endDate = billelement_endDate.getText();

                billCycleDate = billAtrribute_startDate.concat("_").concat(billAtrribute_endDate);
                //System.out.println("Bill Cycle : '" + n+"' -->"+  billCycleDate);
                //read the billcycle graph data - color, tooltip from nodes
                String billchildNodePath_color = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[")
                        .concat(String.valueOf(n).concat("]").concat("/*[name()='path']"));
                //System.out.println("Node billchildNodePath_color : " + billchildNodePath_color);
                WebElement billelement_color = getDriver().findElement(By.xpath(billchildNodePath_color));

                bcAtrribute_color = billelement_color.getAttribute("stroke");
                String colorMap = AppConstants.COLOR.concat(AppConstants.BEGIN_BRACKET).concat(billCycleDate)
                        .concat(AppConstants.CLOSE_BRACKET);
                tempBCGData.put(colorMap, bcAtrribute_color);
                Actions builder = new Actions(getDriver());

                String childMouseHouverNode = bcGraphRootNodeXpath.concat("/*[name()='g']").concat("[")
                        .concat(String.valueOf(n).concat("]"));
                builder.moveToElement(getDriver().findElement(By.xpath(childMouseHouverNode))).perform();

                //System.out.println("childMouseHouverNode : '"+n +"' " +childMouseHouverNode);

                WebElement mouseHoverNodeElement = null;
                mouseHoverNodeElement = getDriver()
                        .findElement(By.xpath("//div[9]/div[1]/div[1]/div[2]/div/div/div"));
                //wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[9]/div[1]/div[1]/div[2]/div/div/div")));

                if (mouseHoverNodeElement != null) {
                    String toolTipText = mouseHoverNodeElement.getText();
                    System.out.println("toolTipText : '" + n + "' " + toolTipText);
                    String toolTipTextMap = AppConstants.TOOL_TIP_TEXT.concat(AppConstants.BEGIN_BRACKET)
                            .concat(billCycleDate).concat(AppConstants.CLOSE_BRACKET);
                    tempBCGData.put(toolTipTextMap, toolTipText);
                    builder.moveToElement(getDriver().findElement(By.xpath(billchildNodePath_startDate)))
                            .click().perform();
                }

            } catch (Exception e) {
                if (e.getMessage().contains("element is not attached")) {
                    //System.out.println("Error: Element 4 ");
                    breakIt = false;
                }
            }
            if (breakIt) {
                break;
            }

        } //while loop ends
        targetBCGraphData_60Days.put(billCycleDate, tempBCGData);
    } //for loop ends
}

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 a v  a  2s  . com*/
    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.digi.selenium.util.BillNReload.Bill_n_Reload_Prepaid_Util.java

protected void targetFinalAmt() {
    WebDriverWait wait = new WebDriverWait(getDriver(), 20);
    try {/*from  w w  w .  j  a  v  a 2s  .c  om*/
        //*[@id='content']/div/div/div[1]/div[9]/div[2]/strong
        wait.until(ExpectedConditions.visibilityOfElementLocated(
                By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong")));
        WebElement amt = getDriver()
                .findElement(By.xpath("//*[@id='content']/div/div/div[1]/div[9]/div[2]/strong"));
        finalamt = amt.getText();
    } catch (Exception e) {
        log.error("Fail : To validate the targetAir time amount on Payment Page");
    }
}

From source file:com.digi.selenium.util.common.PageNavigation.java

protected void socialLinks() {

    try {//from w ww. java  2 s  .c  o m

        JavascriptExecutor jse = (JavascriptExecutor) getDriver();
        jse.executeScript("window.scrollBy(0,1200)", "");
        //                 WebElement fb = (new WebDriverWait(fbdriver, 5000)).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='main']/section/div/ul/li[1]/a")));
        //           fb.click();
        //*[@id="main"]/section/div/ul/li[1]/a
        for (int i = 1; i <= 3; i++) {
            WebElement socialbtn = getDriver()
                    .findElement(By.xpath("//*[@id='main']/section/div/ul/li[" + i + "]/a"));
            Actions newTab1 = new Actions(getDriver());
            newTab1.keyDown(Keys.SHIFT).click(socialbtn).keyUp(Keys.SHIFT).build().perform();
            Thread.sleep(500);

            //handle windows change
            String base1 = getDriver().getWindowHandle();
            Set<String> set1 = getDriver().getWindowHandles();

            set1.remove(base1);
            assert set1.size() == 1;
            getDriver().switchTo().window((String) set1.toArray()[0]);
            waitForPageLoad(500);
            //wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='blueBarNAXAnchor']/div/div/div/div[1]/h1/a/i")));
            //close the window
            getDriver().close();
            getDriver().switchTo().window(base1);

            // handle windows change and switch back to the main window
            Thread.sleep(500);
            for (String winHandle1 : getDriver().getWindowHandles()) {
                getDriver().switchTo().window(winHandle1);

                System.out.println("Link Validation for :" + socialbtn.getText() + " --> Passed");
                log.info("Link Validation for :" + socialbtn.getText() + " --> Passed");
                Thread.sleep(500);
            }
        }
        JavascriptExecutor jse1 = (JavascriptExecutor) getDriver();
        jse1.executeScript("window.scrollBy(0,-1200)", "");
        // jse1.executeScript("window.scrollTo(0,document.body.scrollHeight", "");
        Thread.sleep(500);
    }

    catch (Exception e) {
        log.error("Failed to verify Social Media Links shutting down");
        shutDown();
    }

}

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

License:Open Source License

@Test
public void withModelAndExistingWebView() throws InterruptedException {
    WebElement element = driver.findElement(By.id("target"));
    Assert.assertEquals("Hello", element.getText());
    WebElement button = driver.findElement(By.id("button"));
    button.click();/*ww  w.j  a v  a 2s .  co m*/
    Assert.assertEquals("World", element.getText());
    WebElement input = driver.findElement(By.id("input"));
    input.clear();
    input.sendKeys("DukeScript");
    button.click();
    Assert.assertEquals("DukeScript", element.getText());
    WebElement findElement = driver.findElement(By.cssSelector(".bla"));
    Assert.assertNotNull(findElement);
    Assert.assertEquals("DukeScript", findElement.getText());
    List<WebElement> findElements = driver.findElements(By.cssSelector(".bla"));
    Assert.assertEquals(1, findElements.size());
}

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

License:Open Source License

@Test
public void withModel() {
    // please note that this method is not executed in BrwsrCtx
    // to allow seeing updates in the Browser while debugging a test
    WebElement element = driver.findElement(By.id("target"));
    Assert.assertEquals("Hello", element.getText());
    WebElement button = driver.findElement(By.id("button"));
    button.click();/* ww w. j  a va  2 s .c om*/
    Assert.assertEquals("World", element.getText());
    WebElement input = driver.findElement(By.id("input"));
    input.clear();
    input.sendKeys("DukeScript");
    button.click();
    Assert.assertEquals("DukeScript", element.getText());
    WebElement findElement = driver.findElement(By.cssSelector(".bla"));
    Assert.assertNotNull(findElement);
    Assert.assertEquals("DukeScript", findElement.getText());
}

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

License:Open Source License

@Test
public void findElementByCSSSelector() {
    WebElement element = driver.findElement(By.cssSelector(".css-selector"));
    Assert.assertEquals("blabla", element.getText());
    WebElement child = driver.findElement(By.cssSelector(".parent .child"));
    Assert.assertEquals("blubla", child.getText());

}