title: Python + Selenium get attribute of elements in the list effectively
body: <p>What is the most efficient way to get the same attribute of multiple elements using Python, Selenium and PhantomJS? My solution uses <code>find_elements_by_css_selector</code> which locates all the elements I need, which takes less than a second, then I loop through the list to get the attribute I require. My looping takes over a minute with around 2500 elements, which seems like a lot to me considering all the elements are mapped with <code>find_elements_by_css_selector</code> method. Is <code>get_attribute</code> method really that expensive or am I doing something wrong?</p>
  
  <pre><code>from selenium import webdriver
  
  driver = webdriver.PhantomJS(executable_path=r'mypath\phantomjs.exe')
  driver.set_window_size(1120, 550)
  driver.get("https://www.something.com")
  
  table = []
  elements = driver.find_elements_by_css_selector("tr[id*='bet-']") # takes under 1 second
  
  for element in elements:
     table.append(element.get_attribute('data-info')) # takes over 60 seconds (2000 elements)
  
  driver.close
  </code></pre>