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:cn.aozhi.songify.functional.BaseSeleniumTestCase.java

License:Apache License

/**
 * ?, .//from   w w w. ja v  a  2 s.c  o  m
 */
protected static void loginAsUserIfNecessary() {
    s.open("/task");

    if (s.getTitle().contains("")) {
        s.type(By.name("username"), "user");
        s.type(By.name("password"), "user");
        s.check(By.name("rememberMe"));
        s.click(By.id("submit_btn"));
        s.waitForTitleContains("?");
    }
}

From source file:cn.aozhi.songify.functional.gui.ProfileFT.java

License:Apache License

/**
 * ./*w w  w . ja v  a 2  s .co m*/
 */
@Test
public void editProfile() {
    s.open("/profile");
    s.type(By.id("name"), "Kevin");
    s.click(By.id("submit_btn"));
    assertThat(s.isTextPresent("Kevin")).as("??").isTrue();
}

From source file:cn.aozhi.songify.functional.gui.RegisterFT.java

License:Apache License

@Test
public void register() {
    // //from   w  w  w . j a  v  a2 s .co m
    s.open("/logout");
    s.click(By.linkText(""));

    s.type(By.id("loginName"), "user2");
    s.type(By.id("name"), "Kevin");
    s.type(By.id("plainPassword"), "user2");
    s.type(By.id("confirmPassword"), "user2");

    s.click(By.id("submit_btn"));

    // 
    s.waitForTitleContains("");
    assertThat(s.getValue(By.name("username"))).isEqualTo("user2");

    s.type(By.name("password"), "user2");
    s.click(By.id("submit_btn"));

    // ?
    s.waitForTitleContains("?");

    // 
    s.open("/logout");
}

From source file:cn.aozhi.songify.functional.gui.RegisterFT.java

License:Apache License

@Test
public void inputInValidateValue() {
    s.open("/register");
    s.click(By.id("submit_btn"));

    assertThat(s.getText(By.xpath("//fieldset/div/div/span"))).isEqualTo("");
}

From source file:cn.aozhi.songify.functional.gui.SecurityFT.java

License:Apache License

/**
 * ???./*from  www  .j a  v  a 2s .co m*/
 */
@Test
public void loginWithWrongPassword() {
    s.open("/logout");
    s.type(By.name("username"), "wrongUser");
    s.type(By.name("password"), "WrongPassword");
    s.check(By.name("rememberMe"));
    s.click(By.id("submit_btn"));

    s.waitForTitleContains("");
    assertThat(s.isTextPresent("?.")).isTrue();
}

From source file:cn.aozhi.songify.functional.gui.TaskGuiFT.java

License:Apache License

/**
 * ?.//ww  w. j  ava  2s .c o  m
 */
@Test
@Category(Smoke.class)
public void viewTaskList() {
    s.open("/task/");
    WebElement table = s.findElement(By.id("contentTable"));
    assertThat(s.getTable(table, 0, 0)).isEqualTo("Release SpringSide 4.0");
}

From source file:cn.aozhi.songify.functional.gui.TaskGuiFT.java

License:Apache License

/**
 * //?/.// w ww . ja  v  a  2  s .  co m
 */
@Test
@Category(Smoke.class)
public void crudTask() {
    s.open("/task/");

    // create
    s.click(By.linkText(""));

    Task task = TaskData.randomTask();
    s.type(By.id("task_title"), task.getTitle());
    s.click(By.id("submit_btn"));

    assertThat(s.isTextPresent("?")).isTrue();

    // update
    s.click(By.linkText(task.getTitle()));
    assertThat(s.getValue(By.id("task_title"))).isEqualTo(task.getTitle());

    String newTitle = TaskData.randomTitle();
    s.type(By.id("task_title"), newTitle);
    s.click(By.id("submit_btn"));
    assertThat(s.isTextPresent("?")).isTrue();

    // search
    s.type(By.name("search_LIKE_title"), newTitle);
    s.click(By.id("search_btn"));
    assertThat(s.getTable(By.id("contentTable"), 0, 0)).isEqualTo(newTitle);

    // delete
    s.click(By.linkText(""));
    assertThat(s.isTextPresent("?")).as("??").isTrue();
}

From source file:cn.aozhi.songify.functional.gui.TaskGuiFT.java

License:Apache License

@Test
public void inputInValidateValue() {
    s.open("/task/");
    s.click(By.linkText(""));
    s.click(By.id("submit_btn"));

    assertThat(s.getText(By.xpath("//fieldset/div/div/span"))).isEqualTo("");
}

From source file:cn.aozhi.songify.functional.gui.UserAdminFT.java

License:Apache License

@BeforeClass
public static void loginAsAdmin() {
    s.open("/logout");
    s.type(By.name("username"), "admin");
    s.type(By.name("password"), "admin");
    s.click(By.id("submit_btn"));
}

From source file:cn.aozhi.songify.functional.gui.UserAdminFT.java

License:Apache License

/**
 * ?.//  w  w  w  .j  av a2 s  . c o  m
 */
@Test
@Category(Smoke.class)
public void viewUserList() {
    s.open("/admin/user");
    WebElement table = s.findElement(By.id("contentTable"));
    assertThat(s.getTable(table, 0, 0)).isEqualTo("admin");
    assertThat(s.getTable(table, 1, 0)).isEqualTo("user");
}