Why does this wait code not compile? (Java)
QuizMediumJava only
The file starts with import java.util.*; and import org.openqa.selenium.*; (wildcard imports: each one brings in every class of that package). This line does not compile:
wait.ignoring(NoSuchElementException.class);
Why?
- Both packages have a class named NoSuchElementException, so the name is ambiguous
- ignoring() accepts only TimeoutException
- NoSuchElementException is a checked exception
- WebDriverWait cannot ignore exceptions
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.