Check if “Please enter an email address” message appears

前端 未结 3 1254
灰色年华
灰色年华 2020-12-15 12:15

Given a simple page:

If I enter anything in

3条回答
  •  半阙折子戏
    2020-12-15 12:42

    I haven't found a way to check for the actual error message. However, you can check that the input field is invalid after entering a non-email, using the :invalid CSS pseudo-selector.

    WebElement invalidInput = driver.findElement(By.cssSelector("input:invalid"));
    assertThat(invalidInput.isDisplayed(), is(true));
    

提交回复
热议问题