Search code examples
javaseleniumappium

.contentequals is not throwing exception when returning false


This code was previously working and now for some reason it is not.

TextField1 = THE MOST INTELLIGENT PRIVATE AVIATION SOLUTION IS TAKING OFF Data.firstScreen = THE MOST INTELL!!!IGENT PRIVATE AVIATION SOLUTION IS TAKING OFF

Asserts.TextField1.contentEquals(Data.firstScreen);
Asserts.TextField1.trim().contentEquals(Data.firstScreen);

The above code is always true, as the test does not fail, even though it's supposed to, I also tried .trim(), still passes.

The only thing that works properly is Assert.AssertEquals.

Assert.assertEquals(Asserts.TextField1, Data.firstScreen);

I just printed .contentequals and it returned false correctly, but my code still continues to run, and doesn't stop. No exception seems to be thrown anywhere, and I am not catching any exceptions either.


Solution

  • Figured it out for anyone else that might have the same issue. .contentequals just compares the strings and returns true or false, it's not actually asserting anything.

    You are basically asking it a question and it is returning you an answer, you than have to decide if you want to fail the test or not, otherwise it will just keep running.