-1

Login page, there would be 3 valid scenarios -
1) valid Login
2) Invalid Login
3) Negative Testing scenario

system is expected to prompt the user with an error message.

But a negative testing scenario would be where you are trying to break the application.
For Instance,
1) leaving Password blank,
2) trying to navigate using the URL,
3) using the forward button of the IE bypassing the Login page etc.....

Amith
  • 6,818
  • 6
  • 34
  • 45
Adnan Ghaffar
  • 1,345
  • 7
  • 26
  • 46

1 Answers1

0

Using the getting started with selenium [Java] framework, your test would look something like this.

@Config(url="http://systemunder.test", browser=Browser.FIREFOX)
public class TestLogin extends AutomationTest {
  @Test
  public void testLoginWorks() {
      setText(By.id("username"), "valid_username")
      .setText(By.id("password"), "valid_password")
      .click(By.id("btnLogin"))
      .validatePresent(By.id("logout_link"));
  }

  @Test
  public void testPasswordBlank() {
      setText(By.id("username"), "invalid_username")
      .setText(By.id("password"), "")
      .validateText(By.id("error_message"), "Password is blank.");
  }

  @Test
  public void testUrl() {
      navigateTo("/profile")
      .validateUrl("/login"); // make sure they get redirected to login page.
  }
}
ddavison
  • 28,221
  • 15
  • 85
  • 110