Example usage for org.openqa.selenium WebDriver findElement

List of usage examples for org.openqa.selenium WebDriver findElement

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver findElement.

Prototype

@Override
WebElement findElement(By by);

Source Link

Document

Find the first WebElement using the given method.

Usage

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void openPeoplePage(WebDriver driver1, WebDriverWait wait1) throws IOException {
    logger.info("Open people page");
    driver1.findElement(By.xpath(applangoObject.PEOPLE_PAGE_TAB.getValue())).click();
    wait1.until(ExpectedConditions/*  w  w  w .j  a v a 2 s. c o  m*/
            .visibilityOfAllElementsLocatedBy(By.id(applangoButtons.PEOPLE_PAGE_SEARCH.getValue())));
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void openReportPage(WebDriver driver1, WebDriverWait wait1) throws IOException {
    logger.info("Open Report page");
    driver1.findElement(By.xpath(applangoObject.REPORT_PAGE_TAB.getValue())).click();
    wait1.until(ExpectedConditions/*from   ww w .j av a2 s  . c o m*/
            .visibilityOfAllElementsLocatedBy(By.id(applangoButtons.REPORT_PAGE_SEARCH.getValue())));
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void clickOnReportSearch(WebDriver driver1, WebDriverWait wait1) throws IOException {
    logger.info("Click On report search button");
    driver1.findElement(By.id(applangoButtons.REPORT_PAGE_SEARCH.getValue())).click();
    genericApplangoWebsiteActions.waitUntilWaitForServerDissappears(wait1);
    waitForReportDataHolder(wait1);// www . ja v  a 2  s .  co  m
    waitForReportDataChart(wait1);
    wait1.until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(By.id(applangoButtons.REPORT_PAGE_EXPORT.getValue())));
    wait1.until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(By.id(applangoButtons.REPORT_PAGE_DOWNLOAD.getValue())));
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void selectReportApplication(WebDriver driver1, applications app) throws IOException {
    logger.info("Select application " + app.getValue());
    driver1.findElement(By.id(applangoDropdowns.REPORT_APP_NAME.getValue())).sendKeys(app.getValue());
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void selectReport(WebDriver driver1, applangoReports reportName) throws IOException {
    logger.info("Select Report " + reportName.getValue());
    driver1.findElement(By.id(applangoDropdowns.REPORT_NAME.getValue())).sendKeys(reportName.getValue());
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void clickOnReportExportCSV(WebDriver driver1, WebDriverWait wait1) throws IOException {
    logger.info("click On Report Export CSV");
    driver1.findElement(By.id(applangoButtons.REPORT_PAGE_EXPORT.getValue())).click();
    System.out.println("--- " + driver1.switchTo().activeElement().getText());
    List<String> browserTabs = new ArrayList<String>(driver1.getWindowHandles());
    assertTrue(driver1.switchTo().window(browserTabs.get(1)).getTitle().equals("Applango Report"));
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

public static void clickOnReportDownload(WebDriver driver1, WebDriverWait wait1) throws IOException {
    logger.info("click On Report Download CSV");
    driver1.findElement(By.id(applangoButtons.REPORT_PAGE_DOWNLOAD.getValue())).click();
    wait1.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@id=\"buttons\"]/output/a")));
}

From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java

private static void clickOnApplicationLink(WebDriver driver) throws IOException {
    driver.findElement(By.xpath(applangoObject.APPLICATION_LINK.getValue())).click();
}

From source file:application.Main.java

License:Open Source License

public static void appSingleThread(Globals GLOBALS) {
    LinkedList<String> list = Input.readFacebookPostIds(GLOBALS.FILENAME);
    if (GLOBALS.RANDOM) {
        Collections.shuffle(list);
    }/*from   w w w . j  a va2  s.  co  m*/
    String email = GLOBALS.fb_eamil;
    String pass = GLOBALS.password;
    WebDriver driver = new FirefoxDriver(); // The Firefox driver supports javascript 
    Autenticate.perform(driver, email, pass);
    try {
        Thread.sleep(Globals.TIME_TO_LOGIN_IN_FB_MS);
    } catch (Exception ex) {
        System.out.println("InterruptedException in crawl.run()");
        ex.printStackTrace();
        System.exit(-1);
    }
    for (String post_id : list) {
        System.out.println("\n****** STARTING NEW TREE: " + post_id + "******");
        try {
            //OPEN NEW TAB
            WebElement body = driver.findElement(By.tagName("body"));
            body.sendKeys(Keys.CONTROL + "t");
            Tree post = new Tree(post_id, GLOBALS);
            boolean result = post.crawl(driver);
            if (result) {
                post.prune();
                post.print();
                post.printEdgeList();
                System.out.println("****** TREE " + post_id + " ACCOMPLISHED ******");
            } else {
                body.sendKeys(Keys.CONTROL + "w");
                System.out.println("****** TREE " + post_id + " FAILED ******");
            }
            //SWITCH TAB
            ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles());
            driver.switchTo().window(tabs.get(tabs.size() - 1));
        } catch (Exception e) {
            System.out.println("****** TREE " + post_id + " FAILED ******");
            System.out.println("EXCEPTION in MAIN " + e);
            System.out.println("...RESTARTING APPLICATION AFTER 1 minute APPLICATION...");
            driver.quit();
            try {
                Thread.sleep(Globals.ONE_MINUTE);
            } catch (Exception ex) {
                System.out.println("InterruptedException in crawl.run()");
                ex.printStackTrace();
                System.exit(-1);
            }
            driver = new FirefoxDriver(); // The Firefox driver supports javascript 
            Autenticate.perform(driver, email, pass);
        }
    }
    driver.quit();
}

From source file:AQ.TeamsUnitTest.java

@Test
public void hello() {
    WebDriver driver = webDriver;
    int noTeams = 3;

    driver.get(baseUrl + "/champgen/faces/index.xhtml");
    driver.findElement(By.linkText("Login")).click();
    driver.findElement(By.id("login-form:username")).sendKeys("admin");
    driver.findElement(By.id("login-form:password")).sendKeys("admin");
    driver.findElement(By.id("login-form:btnSubmit")).click();
    driver.findElement(By.linkText("New Championship")).click();
    driver.findElement(By.id("new-championship-form:name")).clear();
    driver.findElement(By.id("new-championship-form:name")).sendKeys("TestChamp1");
    driver.findElement(By.id("new-championship-form:btnSubmit")).click();
    assertTrue(driver.findElement(By.id("msg:info")).getText().matches("^[\\s\\S]*added ![\\s\\S]*$"));

    for (int i = 0; i < noTeams; i++) {
        driver.findElement(By.linkText("New Team")).click();
        driver.findElement(By.id("newteam-form:team")).clear();
        driver.findElement(By.id("newteam-form:team")).sendKeys("Team" + i);
        driver.findElement(By.id("newteam-form:leader")).clear();
        driver.findElement(By.id("newteam-form:leader")).sendKeys("Leader" + i);
        driver.findElement(By.id("newteam-form:btnSubmit")).click();
    }//from ww  w  .  ja v a  2  s . c o  m

    this.pause(TIME_TO_PAUSE);
    this.pause(TIME_TO_PAUSE);

    driver.get(baseUrl + "/champgen/faces/index.xhtml");

    int rowCount = webDriver.findElements(By.xpath("//table/tbody/tr")).size();
    System.out.println(rowCount);
    assertTrue(rowCount == noTeams + 1); // + 1 because title is counted as row

    this.pause(TIME_TO_PAUSE);
}