2

In C#:

  Assert.IsTrue(NewPagePost.IsInEditMode(), ""wasn't in edit mode");

  Assert.AreEqual("Sample Page", NewPostPage.Title, "Title did not match");

What is the Java alternative for Assert.IsTrue and Assert.AreEqual ?

Is the below code right :

   Assert.assertTrue("wasn't in edit mode", NewPostPage.IsInEditMode());
   Assert.assertEquals("Sample Page,", NewPostPage.getTitle(),"Title did not match");
rrene
  • 313
  • 1
  • 3
  • 14
  • Java doesn't have a built-in `Assert` class. Are you using JUnit? – ajb Dec 23 '15 at 05:47
  • No, I am using Selenium Webdriver.. – rrene Dec 23 '15 at 05:57
  • 1
    I don't know anything about Selenium Webdriver. It looks like you're asking about unit testing. I think you probably want JUnit. See http://stackoverflow.com/questions/10577254/first-steps-with-selenium-and-junit-any-good-tutorials (even though it's closed, somebody posted some links anyway). – ajb Dec 23 '15 at 06:21

1 Answers1

1
Assert.assertTrue("wasn't in edit mode", NewPostPage.IsInEditMode());
Assert.assertEquals("Sample Page,", NewPostPage.getTitle(),"Title did not match");

The above looks good.

You can rewrite the second statement as

Assert.assertTrue("Sample Page".equals(NewPostPage.getTitle()),"Title did not match");
Pétur Ingi Egilsson
  • 4,368
  • 5
  • 44
  • 72