Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97750

Python Selenium Scrape selectors with their respective text [closed]

$
0
0

I am trying to write a program that writes code for me. Imagine i have a UL list on a website and i need to scrape all the xapth selectors for each elements in the list. Is there an easy way to tell python to grab the xpath selectors for all of the elements in the UL?

<ul id="test">
    <li><a href="#">Zurich</a></li>
    <li><a href="#">Geneva</a></li>
    <li><a href="#">Winterthur</a></li>
    <li><a href="#">Lausanne</a></li>
    <li><a href="#">Lucerne</a></li>
  </ul>

Python code

ul= driver.find_elements_by_id('test')

for element in ul:
    selector = **find the xpath/selector**
    text = element.text  

Thank you!


Viewing all articles
Browse latest Browse all 97750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>