예제 #1
0
 @Test
 public void userCanAddWebDriverListeners() {
   WebDriverEventListener listener1 = mock(WebDriverEventListener.class);
   WebDriverRunner.addListener(listener1);
   Configuration.browser = HTMLUNIT;
   open(url);
   verify(listener1).beforeNavigateTo(eq(url.toString()), any(WebDriver.class));
 }
예제 #2
0
  @Test
  public void allowsToSpecifyCustomWebDriverProgrammatically() {
    HtmlUnitDriver myDriver = new HtmlUnitDriver(true);
    WebDriverRunner.setWebDriver(myDriver);

    open(url);
    assertSame(myDriver, WebDriverRunner.getWebDriver());
  }
예제 #3
0
  @Test
  public void testEnvioNumeroInvalido() {
    open("http://localhost:8080/");
    $(By.id("messageBox")).setValue("Mensaje de prueba");
    $(By.id("phoneNumber")).setValue("abcdef");
    $(By.id("submitButton")).click(); // Este id no existía

    $(By.id("resultado")).shouldHave(text("no es un número válido"));
  }
예제 #4
0
  @Test
  public void testEnvioOK() {
    open("http://localhost:8080/");
    $(By.id("messageBox")).setValue("Mensaje de prueba");
    $(By.id("phoneNumber")).setValue("310258369");
    $(By.id("submitButton")).click(); // Este id no existía

    $(By.id("resultado")).shouldHave(text("recibido"));
  }
예제 #5
0
 @Test
 public void selenideArticle() {
   open("http://habrahabr.ru/post/143269/");
   $(".post__title").shouldHave(text("Selenide: удобные тесты на Selenium WebDriver"));
   $(By.linkText("Selenium WebDriver"))
       .shouldHave(attribute("href", "http://code.google.com/p/selenium/"));
   $(By.linkText("Selenide"), 0).shouldHave(attribute("href", "http://ru.selenide.org/"));
   $(By.linkText("Selenide"), 1).shouldHave(attribute("href", "http://ru.selenide.org/"));
   $(By.linkText("в нашей фирме")).shouldHave(attribute("href", "http://ru.codeborne.com/"));
   $(By.linkText("игра Виселица"))
       .shouldHave(attribute("href", "https://github.com/asolntsev/hangman"));
 }
예제 #6
0
  private void ensureOpenedTodoMVCPage() {

    if (!getWebDriver().getCurrentUrl().equals(toDoMVCPageUrl)) {
      open(toDoMVCPageUrl);
    }
  }
예제 #7
0
 private void smartOpenTodoMVCPage() {
   if ($("#new-todo").is(not(visible))) {
     open("http://todomvc.com/examples/troopjs_require/#/");
     getWebDriver().navigate().refresh();
   }
 }