The webpage have a code:
<table> <tbody> <tr> <td> <time data-timestamp="1458895194718" title="2016-03-25 11:39:54<small class="milliseconds">.718</small>">11:39</time> </td> <td> <span class="invisep"><</span> <mark class="nickname" style="cursor:pointer; color:#03DC03">usernickname</mark> <span class="invisep">></span> </td>
I need to get style= and I received advice to use:
from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.firefox.webdriver import FirefoxProfile colorelement = driver.find_element_by_css_selector('mark.nickname') color = colorelement.get_attribute('style')
and it works but my code returns me only the first value found. The web page have many blocks and everyone has block The code find_elements_by_css_selector
returns "AttributeError: 'list' object has no attribute 'get_attribute'" Could you help me please, how can I get second(third etc.) value or maybe it can be found all the values at once
find_element_*
which only returns the first match even if there are more than one. It sounds like you wantfind_element**s**_*
which will return all the elements that match. See Florent B.'s answer below.