I just want to create an object of class, but got this error when debugging. Can anybody tell me what the problem is? The location of this code is in some Spring(2.5) Servic
In my case it was due to the object reference getting stale. I was automating my application using selenium webdriver, so i type something into a text box and then it navigates to another page, so while i come back on the previous page , that object gets stale. So this was causing the exception, I handled it by again initialising the elements - PageFactory.initElements(driver, Test.class;
I got similar exception in Eclipse. This was due to java.lang.StackOverflowError
error. I had overriden toString()
method in child class, having JoinColumn
, which was returning string using object of parentclass, resulting in circular dependency. Try to remove that object from toString()
, and it will work.
There could be two reasons an element doesn't exist:
Would you get com.sun.jdi.InvocationException in either case when you are running Debug and you hover your mouse over a reference to the WeBElement (this with Selenium and Java)???
We use the following, but can't distinguish if it returns false due to bad xpath or non-existent element (valid xpath syntax):
public static boolean isElementDisplayed(WebElement element) {
boolean isDisplayed = false;
try {
isDisplayed = element.isDisplayed();
} catch (NoSuchElementException e) {
;// No Worries
}
return isDisplayed;
}
I faced the same problem once. In my case it was because of overridden equals
method. One values was coming null
.
Well, it might be because of several things as mentioned by others before and after. In my case the problem was same but reason was something else.
In a class (A), I had several objects and one of object was another class (B) with some other objects. During the process, one of the object (String) from class B was null, and then I tried to access that object via parent class (A).
Thus, console will throw null point exception but eclipse debugger will show above mentioned error.
I hope you can do the remaining.
I also faced the same problem. In my case I was hitting a java.util.UnknownFormatConversionException
. I figured this out only after putting a printStackTrace
call. I resolved it by changing my code as shown below.
from:
StringBuilder sb = new StringBuilder();
sb.append("***** Test Details *****\n");
String.format("[Test: %1]", sb.toString());
to:
String.format("[Test: %s]", sb.toString());