2

I have this HTML code:

<caption>
    <em id="qwerty"> ABC </em>
</caption>

<caption>
    <em id="qwerty"> 123 </em>
</caption>

How can I make a program in Python with Selenium Webdriver that finds the second element with id="qwerty"?

1
  • It might be worth pointing out, that two elements with the same id attribute on one page is a defect. Commented Jun 25, 2014 at 16:48

1 Answer 1

1

You can use find_elements_by_id() and take the second element (indexing in python starts from 0):

element = driver.find_elements_by_id('qwerty')[1]
Sign up to request clarification or add additional context in comments.

1 Comment

If I have a parent web element, how I use this to find the next element?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.