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

Quiz: Locators · Question 9 of 10

Why is By.className often a poor choice?

Why is By.className often a poor choice?

  1. A.It is slower than XPath
  2. B.Classes are usually shared by many elements, so it is rarely unique
  3. C.It does not work in Chrome
  4. D.It can only find buttons
Answer & explanation

Correct answer: Classes are usually shared by many elements, so it is rarely unique

Prefer id, name, a data-testid attribute or a precise CSS selector.

Can you get the rest right without peeking?

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

Start the quiz →