コード例 #1
0
  @Test
  public void testAddingADuplicateReview() throws Exception {
    final Map<String, String> reviewFormInfo = TestData.getCommentFormValues();

    generateNewProductReview(reviewFormInfo);
    Thread.sleep(2000);
    generateNewProductReview(reviewFormInfo);

    String error = findElement(By.id("error-page")).getText();
    assertEquals(
        "Duplicate comment detected; it looks as though you\u2019ve already said that!", error);
  }
コード例 #2
0
  @Test
  public void testAddNewReview() throws Exception {
    HashMap<String, String> overwrite = new HashMap<String, String>();
    overwrite.put("name", "Dima");
    Map<String, String> reviewFormInfo = TestData.getCommentFormValues(overwrite);
    String reviewId = generateNewProductReview(reviewFormInfo);

    WebElement review = findElement(By.id(reviewId));

    String name =
        review
            .findElement(By.className("comment-author-metainfo"))
            .findElement(By.className("url"))
            .getText();
    String comment = review.findElement(By.className("comment-content")).getText();

    assertEquals("Dima", name);
    assertEquals(reviewFormInfo.get("comment"), comment);
  }