Skip to content
CodeKruPro

Two elements share one id

Automation taskEasy-MediumPython onlyAsked in: Accenture, Capgemini, Wipro

Asked as: "Two elements have the same attributes. Which one does find_element return, and how do you pick the second?" It returns the first match in the page, which may be a hidden copy. Count the matches with find_elements and check which one is displayed.

Two Elements Share One ID

Two Elements Share One ID

An id is supposed to be unique. This page has two elements with id firstName. find_elements returns both. find_element returns only the first.

Task:

  1. Find every element with id firstName
  2. Print how many there are
  3. Print whether the first one is displayed

Print the lines below exactly.

Expected output:

Matches: 2
First displayed: True