vendredi 13 décembre 2019

How to make test case fail if values are matching

I have a scenario where I need to edit Employee name and when I click on Cancel button, Employee name field will wound back to its original value.Now I have to verify Cancel button is working or not.For that my approach is:

  • 1.Get the value from the field using get attribute

  • 2.Clear the field and enter new employee name

  • 3.Click on cancel

  • 4.Compare get attribute value and new employee name

My question is how do I fail the test case if both attribute value and new employee name are same.I used both If condition and Assert condition.Both are not working.Any solutions to this

 Assert.assertTrue(getLastNameValue.equals(LastName));.//It will fail if both the values mismatch.but i want to make it fail only if both the values are equal

And one more method I tried

if(!getLastNameValue.equalsIgnoreCase(LastName)) {
        log.info("Edits are wounded back after clicking on Cancel button");
    }

Aucun commentaire:

Enregistrer un commentaire