I would suggest a slightly different approach. I would grab the entire text and then split one time on
:. That will get you the title and the value. The code below will get Paalcode through openingstijden labels.
for x in range(2, 8): s = driver.find_element_by_css_selector("div.leftblock > div.labels > div")[x].text t = s.split(":", 1) print(t) # title print(t) # value
You don't want to split more than once because Status contains more semicolons.
find_element_by_xpath() method returns the first element node matching the given XPath query, if any. However, XPath's
text() function returns a text node—not the element node that contains it.
To extract the text using Selenium's finder methods, you'll need to find the containing element, then extract the text from the returned object.