1

Using XPath in Selenium or BeautifulSoup in Python, how can one get the tag-names (here 'a', 'button') and the values of 'aria' attributes (here Home, True, False) by knowing that those attributes start with 'aria'

<a aria-label="Home" id="1" />
<button aria-hidden="True" id="2" />
<button aria-pressed="False" id="2" />

Currently, I have to put in all attributes one-by-one, like this

driver.find_elements_by_xpath("//*[@aria-label]")
driver.find_elements_by_xpath("//*[@aria-pressed]")

What I need is something like (which, here, isn't correct),

driver.find_elements_by_xpath("//*@[starts-with('aria')]")
Andersson
  • 49,746
  • 15
  • 64
  • 117
solyarist
  • 404
  • 3
  • 16
  • checkout this: https://stackoverflow.com/questions/27307131/selenium-webdriver-how-do-i-find-all-of-an-elements-attributes – Infern0 Oct 08 '18 at 06:46

0 Answers0