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
  • 51,635
  • 17
  • 77
  • 129
solyarist
  • 424
  • 3
  • 17
  • 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