Sebastian Nielsen Sebastian Nielsen - 11 months ago 49
Python Question

python selenium - locating a text on a website, and storing it in a variable
This is the one text I want to store in a variable from the website.
How do I do that?
This is what I came up with:

text = browser.find_elements_by_css_selector('.vip-additional-text > *:nth-child(1) > p')



It returns an empty list for some reason, can anyone help me please?

Answer Source

If you want the text and not the webElement you should try:

text = browser.find_element_by_class_name("vip-additional-text").text