Reputation: 18634
I want to validate the presence of a text using assertTrue(), but I am getting a StackOverflow error. I am not sure that the code I have written is correct or not. Need your suggestions.
// Checking the posted text
WebElement postedtext= driver.findElement(By.cssSelector("css123"));
assertTrue("The text is verfied",postedtext.getText().equals(enteredText));
private static void assertTrue(String string, boolean equals) {
assertTrue(string,equals);}
Upvotes: 1
Views: 5278
Reputation: 2406
It is a name conflicting that you happened to name you assert method the same name as the library method. Rename your assertTrue
can solve the problem.
// Checking the posted text
WebElement postedtext= driver.findElement(By.cssSelector("css123"));
myAssertTrue("The text is verfied",postedtext.getText().equals(enteredText));
private static void myAssertTrue(String string, boolean equals) {
try {
assertTrue(string,equals);
} catch (AssertionError e) {
System.out.println(e.getMessage());
throw e;
}
}
Or you just delete your assertTrue
and use the library method instead.
Upvotes: 2
Reputation: 11832
You have a method called assertTrue(s, b)
which calls itself. This is causing an infinite recursion.
Upvotes: 3