🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Selenium Setup: all 10 questions

Quiz: Selenium Setup · Question 7 of 10

driver.findElement(By.id("missing")) is called and no element matches. What happens?

driver.findElement(By.id("missing")) is called and no element matches. What happens?

  1. A.It returns null
  2. B.It returns an empty list
  3. C.It throws NoSuchElementException
  4. D.It waits forever
Answer & explanation

Correct answer: It throws NoSuchElementException

Use findElements when absence is a normal, expected result.

Can you get the rest right without peeking?

Take the timed Quiz: Selenium Setup quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →