title: Selenium Assertion for Negative Scenario Java
body: <p>I'm trying to assert a negative test case for gmail login in selenium but ending up with getting an exception. Could anyone suggest what's the issue?</p>
  
  <pre><code> @Test(dataProvider="LoginData")
  public void testMethod(String email,String password) throws InterruptedException{
              browser.findElement(By.id("Email")).clear();
              browser.findElement(By.id("Email")).sendKeys(email);
              browser.findElement(By.id("Passwd")).sendKeys(password);
              browser.findElement(By.id("signIn")).click();
              browser.wait(30000);
              assertTrue(browser.getPageSource().contains("The username or password you entered is incorrect."));
  </code></pre>
  
  <p>}</p>
  
  <p>Generated exception</p>
  
  <pre><code>java.lang.IllegalMonitorStateException
  at java.lang.Object.wait(Native Method)
  at seleniumExcel.DataProviderAutomation.testMethod(DataProviderAutomation.java:38)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
  at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
  at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
  at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
  at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
  at org.testng.TestRunner.privateRun(TestRunner.java:767)
  </code></pre>