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!