title: Parsing HTML5 data-* attribute values with Selenium in Python
body: <p>I am parsing a JS generated webpage like so:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  
  
  driver = webdriver.Firefox()
  driver.get('https://www.consumerbarometer.com/en/graph-builder/?question=M1&amp;filter=country:singapore,canada,mexico,brazil,argentina,united_states,bulgaria,austria,belgium,croatia,czech_republic,denmark,estonia,finland,france,germany,greece,hungary,italy,ireland,latvia,lithuania,norway,netherlands,poland,portugal,russia,romania,serbia,slovakia,spain,slovenia,sweden,switzerland,ukraine,united_kingdom,australia,china,israel,hong_kong_sar,japan,korea,new_zealand,malaysia,taiwan,turkey,vietnam')
  
  // wait for svg to appear
  WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.TAG_NAME, 'svg')))
  
  for text in driver.find_elements_by_class_name('bar-text-label'):
      print(text.text)
  
  driver.close()
  </code></pre>
  
  <p>Besides getting the <code>text</code> from the class <code>bar-text-label</code> I would also like to get values from an HTML5 data-attribute. For example,<code>&lt;rect rx="3" ry="3" width="76%" height="40" transform="translate(0,40)" data-value="76" class="bar"&gt;&lt;/rect&gt;</code> and I would like to be able to parse <code>76</code> from this. </p>
  
  <p>Is this possible to do in Selenium?</p>
  
  <p>I tried both of the below, with no sucess:</p>
  
  <pre><code>for text in driver.find_elements_by_class_name('bar'): 
      print(data_value.text)
  
  for data in driver.find_elements_by_xpath('//*[contains(@data-value)]/@data-value'): 
      print(data.text)
  </code></pre>