This I know is a very simple question. I'm quite sick and trying to finish up this presentation and my brain just doesn't seem to be working right.
The HTML code is as follows:
The problem is that you cannot directly locate the "text" nodes with
find_element_* commands in selenium - the locators you use have to point to actual elements.
In this case, I would get the
p element's text, split by
: and get the last item:
text = driver.find_element_by_xpath("//p[b = 'Postal code:']").text postal_code = text.split(":")[-1].strip() print(postal_code)