Closed
Description
Feature and motivation
I suggest adding JSpecify Nullness annotations to the Selenium framework code.
These annotations allow you to specify which parameters and return values can be null.
I'm aware that information about potential null values are already placed in the JavaDoc, but using annotations will be transparent to IDEs and static code analyzers.
This will give developers better exposure of potential problems with their code in order to avoid NullPointerExceptions.
Using annotations will also improve interoperability with Kotlin.
Links:
Usage example
The annotated method would look like this:
// ...
import org.jspecify.annotations.Nullable;
public interface WebElement extends SearchContext, TakesScreenshot {
// ...
@Nullable String getAttribute(String name);
// ...
}
Then the IDE/static code analyzer will display a warning about unsafe code:
var element = webDriver.findElement(By.tagName("img"));
var cssClasses = element.getAttribute("class").split(" "); // warning here, possible NullPointerException