Exemplo n.º 1
0
 private void givenEmptyTodoMVCPage() {
   smartOpenTodoMVCPage();
   if (tasks.size() > 0) {
     executeJavaScript("localStorage.clear()");
     getWebDriver().navigate().refresh();
   }
 }
  @Test
  public void shouldWaitsUntilElementIsReplaced() {
    $("#dynamic-element").shouldHave(value("I will be replaced soon"));

    executeJavaScript("replaceElement()");
    $("#dynamic-element").shouldHave(value("Hello, I am back"), cssClass("reloaded"));
    $("#dynamic-element").setValue("New value");
  }
 @Test
 @Ignore
 public void tryToCatchStaleElementException() {
   executeJavaScript("startRegularReplacement()");
   for (int i = 0; i < 10; i++) {
     $("#dynamic-element")
         .shouldHave(value("I am back"), cssClass("reloaded"))
         .setValue("New value from test");
   }
 }
Exemplo n.º 4
0
  private void given(Task... tasks) {

    ensureOpenedTodoMVCPage();
    StringBuilder jsStringBuilder =
        new StringBuilder("localStorage.setItem(\"todos-troopjs\", \"[");

    for (int i = 0; i < tasks.length; i++) {
      String taskData = tasks[i].toString();

      jsStringBuilder.append(taskData);
      if (i < tasks.length - 1) {
        jsStringBuilder.append(",");
      }
    }
    jsStringBuilder.append("]\")");

    executeJavaScript(jsStringBuilder.toString());
    getWebDriver().navigate().refresh();
  }
Exemplo n.º 5
0
  private void given(Task... tasks) {
    givenEmptyTodoMVCPage();
    StringBuilder jsStringBuilder =
        new StringBuilder("localStorage.setItem(\"todos-troopjs\", \"[");
    int i = 0;
    for (Task task : tasks) {
      String taskData = task.toString();
      if (i < tasks.length - 1) {
        jsStringBuilder.append(taskData).append(", ");
      } else if (i == tasks.length - 1) {
        jsStringBuilder.append(taskData);
      }
      i++;
    }
    jsStringBuilder.append("]\")");

    executeJavaScript(jsStringBuilder.toString());
    getWebDriver().navigate().refresh();
  }