Example usage for org.openqa.selenium By id

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

Introduction

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

Prototype

public static By id(String id) 

Source Link

Usage

From source file:CertMaven.pageObjects.DriverPage.java

public DriverReportsPage ClickContinueButtonInquiry() throws Throwable {

    try {/*from  w  ww .j  ava  2s. co  m*/
        driver.findElement(By.id("policyDataGatherForm:nextInquiry")).click();
    } catch (Exception e) {
        Thread.sleep(2000);
        driver.findElement(By.id("policyDataGatherForm:nextInquiry")).click();

    }

    return new DriverReportsPage(driver);
}

From source file:ch.admin.isb.hermes5.common.AbstractPageDriver.java

License:Apache License

public WebElement findElementById(String id) {
    return findElement(By.id(id));
}

From source file:ch.hearc.arcgames.tests.AdminSecurityTest.java

private void login(String username, String passwd) {
    driver.findElement(By.linkText("Log in")).click();
    driver.findElement(By.id("j_idt19:login")).clear();
    driver.findElement(By.id("j_idt19:login")).sendKeys(username);
    driver.findElement(By.id("j_idt19:passwd")).clear();
    driver.findElement(By.id("j_idt19:passwd")).sendKeys(passwd);
    driver.findElement(By.id("j_idt19:submit")).click();
}

From source file:ch.hearc.arcgames.tests.DBInteractionTest.java

@Test
public void loggedUserTryAccessPages() throws Exception {

    // New user informations
    String username = "myUsername";
    String mail = "myMail@gmail.com";
    String location = "Neuchtel";
    String firstName = "myFName";
    String lastName = "myLName";
    String passwd = "myPasswd";

    // We open the web app
    driver.get(baseUrl + "/ArcGames/");

    // SignUp with a test user
    signUp(username, mail, passwd, location, firstName, lastName);

    // Login as non-admin
    login(username, passwd);/*from  w ww  .j  av  a2s .  c o m*/

    // Edit user
    String s = "edited";
    driver.findElement(By.linkText(username)).click();
    driver.findElement(By.id("j_idt19:username")).clear();
    driver.findElement(By.id("j_idt19:username")).sendKeys(s);
    driver.findElement(By.id("j_idt19:mail")).clear();
    driver.findElement(By.id("j_idt19:mail")).sendKeys(s);
    driver.findElement(By.id("j_idt19:passwd")).clear();
    driver.findElement(By.id("j_idt19:passwd")).sendKeys(s);
    driver.findElement(By.id("j_idt19:passwdConfirm")).clear();
    driver.findElement(By.id("j_idt19:passwdConfirm")).sendKeys(s);
    driver.findElement(By.id("j_idt19:location")).clear();
    driver.findElement(By.id("j_idt19:location")).sendKeys(s);
    driver.findElement(By.id("j_idt19:firstName")).clear();
    driver.findElement(By.id("j_idt19:firstName")).sendKeys(s);
    driver.findElement(By.id("j_idt19:lastName")).clear();
    driver.findElement(By.id("j_idt19:lastName")).sendKeys(s);
    driver.findElement(By.id("j_idt19:submit")).click();

    // Logout
    driver.findElement(By.linkText("logout")).click();

}

From source file:ch.hearc.arcgames.tests.DBInteractionTest.java

private void signUp(String username, String mail, String passwd, String location, String firstName,
        String lastName) {/* w  w w.  j a  v a 2 s .  c  om*/
    driver.findElement(By.linkText("Sign up")).click();
    driver.findElement(By.id("j_idt18:username")).clear();
    driver.findElement(By.id("j_idt18:username")).sendKeys(username);
    driver.findElement(By.id("j_idt18:mail")).clear();
    driver.findElement(By.id("j_idt18:mail")).sendKeys(mail);
    driver.findElement(By.id("j_idt18:passwd")).clear();
    driver.findElement(By.id("j_idt18:passwd")).sendKeys(passwd);
    driver.findElement(By.id("j_idt18:passwdConfirm")).clear();
    driver.findElement(By.id("j_idt18:passwdConfirm")).sendKeys(passwd);
    driver.findElement(By.id("j_idt18:location")).clear();
    driver.findElement(By.id("j_idt18:location")).sendKeys(location);
    driver.findElement(By.id("j_idt18:firstName")).clear();
    driver.findElement(By.id("j_idt18:firstName")).sendKeys(firstName);
    driver.findElement(By.id("j_idt18:lastName")).clear();
    driver.findElement(By.id("j_idt18:lastName")).sendKeys(lastName);
    driver.findElement(By.id("j_idt18:submit")).click();
}

From source file:ch.hearc.arcgames.tests.searchTest.java

private void simpleSearch(String pattern) {
    driver.findElement(By.id("j_idt18:search")).clear();
    driver.findElement(By.id("j_idt18:search")).sendKeys(pattern);
    driver.findElement(By.id("j_idt18:submit")).click();
}

From source file:ch.hearc.arcgames.tests.searchTest.java

private void advancedSearch(String pattern) {
    driver.findElement(By.id("j_idt18:advenced")).click();
    driver.findElement(By.id("j_idt18:search")).clear();
    driver.findElement(By.id("j_idt18:search")).sendKeys(pattern);
    driver.findElement(By.id("j_idt18:firstNameSearch")).clear();
    driver.findElement(By.id("j_idt18:firstNameSearch")).sendKeys(pattern);
    driver.findElement(By.id("j_idt18:lastNameSearch")).clear();
    driver.findElement(By.id("j_idt18:lastNameSearch")).sendKeys(pattern);
    driver.findElement(By.id("j_idt18:locationSearch")).clear();
    driver.findElement(By.id("j_idt18:locationSearch")).sendKeys(pattern);
    driver.findElement(By.id("j_idt18:submit")).click();
}

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

License:Apache License

/**
 * Go to the edit page.//from  ww  w  . j  ava 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.vaadin.designer.tests.web.DesignerWebDriverTest.java

License:Apache License

@Test
public void testDraggingFieldInBrowserAssertModelChanged() throws Exception {
    WebElement fieldToDrag = driver.findElement(By.id("name"));
    action.clickAndHold(fieldToDrag).moveByOffset(100, 200).release().build().perform();

    // Because the WD affects a Jetty HTTP Worker thread, the change to
    // the EMF model won't be visible yet if this runs too fast, so:
    Thread.sleep(500);//from www.jav a  2s  . co m
    assertEquals(120, screen.getFields().get(0).getX());
    assertEquals(210, screen.getFields().get(0).getY());
}

From source file:ch.vorburger.vaadin.designer.tests.web.DesignerWebDriverTest.java

License:Apache License

@Test
public void testChangeModelAssertFieldMovedInBrowser() throws Exception {
    screen.getFields().get(0).setX(44);/*from   w  w w  . j a  va2s .  c  o m*/
    screen.getFields().get(0).setY(56);

    WebElement fieldToDrag = driver.findElement(By.id("name"));
    WebElement parentDIV = fieldToDrag.findElement(By.xpath(".."));
    assertEquals("44px", parentDIV.getCssValue("left"));
    assertEquals("56px", parentDIV.getCssValue("top"));
}