OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Finding the <section> elements with Selenium in Python

  • Thread starter Thread starter luis torres
  • Start date Start date
L

luis torres

Guest
I've been trying to use the find_elements() method of Selenium to extract the element of a webpage, there are 3 elements but the code is only fetching the first one.

This is the part of the code where I'm using the find_elements function:

sections = driver.find_elements(by = By.XPATH, value = '//section[@data-test]')

This image is a portion of the webpage that I'm scrapping.

I used the same code to fetch all the
  • elements of the same webpage and it work, I don't understand what I'm doing wrong with the elements, so how can I do to fetch the 3 section elements?
<p>I've been trying to use the find_elements() method of Selenium to extract the element of a webpage, there are 3 elements but the code is only fetching the first one.</p>
<p>This is the part of the code where I'm using the find_elements function:</p>
<p><code>sections = driver.find_elements(by = By.XPATH, value = '//section[@data-test]')</code></p>
<p>This <a href="https://i.sstatic.net/oII7VPA4.png" rel="nofollow noreferrer">image</a> is a portion of the webpage that I'm scrapping.</p>
<p>I used the same code to fetch all the <li> elements of the same webpage and it work, I don't understand what I'm doing wrong with the elements, so how can I do to fetch the 3 section elements?</p>
 
Top